Posted 25 Jan 2011 Link to this post
this
.RowLoaded +=
new
EventHandler<RowLoadedEventArgs>(CustomTabTreeListView_RowLoaded);
.RowUnloaded +=
EventHandler<RowUnloadedEventArgs>(CustomTabTreeListView_RowUnloaded);
void
CustomTabTreeListView_RowUnloaded(
object
sender, RowUnloadedEventArgs e)
{
TreeListViewRow row = e.Row
as
TreeListViewRow;
if
(row !=
null
)
row.Cells.ToList().ForEach(t => t.RemoveHandler(GridViewCellBase.MouseLeftButtonDownEvent,
EventHandler<MouseButtonEventArgs>(CustomTabTreeListView_Cell_MouseLeftButtonDown)));
}
CustomTabTreeListView_RowLoaded(
sender, RowLoadedEventArgs e)
row.Cells.ToList().ForEach(t => t.AddHandler(GridViewCellBase.MouseLeftButtonDownEvent,
EventHandler<MouseButtonEventArgs>(CustomTabTreeListView_Cell_MouseLeftButtonDown),
true
));
private
CustomTabTreeListView_Cell_MouseLeftButtonDown(
sender, MouseButtonEventArgs e)
Have you defined CellTemplate in RadTreeListView's columns? If that is the case you may take a look at the following forum thread "Gridview cell click event" and you will understand how to fire this event in an appropriate manner.
Posted 26 Jan 2011 Link to this post
Another approach would be to add a handler directly to the RadTreeListView and verify that you have a clicked on a cell:
public MainPage()
InitializeComponent();
this.RadTreeListView1.AddHandler(GridViewCellBase.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnMouseLeftButtonDown), true);
var clickedElement = e.OriginalSource as FrameworkElement;
if (clickedElement != null)
var cell = clickedElement.ParentOfType<
GridViewCell
>();
if(cell != null)
MessageBox.Show("You clicked on a cell");
Posted 27 Jan 2011 Link to this post