Hello,
What is the best way to detect when a TreeViewItem is removed from the TreeView?
I'm looking for the opposite of ItemPrepared e.g. ItemRemoved
I've tried subscribing to the Unloaded event but this does not fire when the item is removed from the TreeView i.e.
Help appreciated,
James.
What is the best way to detect when a TreeViewItem is removed from the TreeView?
I'm looking for the opposite of ItemPrepared e.g. ItemRemoved
I've tried subscribing to the Unloaded event but this does not fire when the item is removed from the TreeView i.e.
public partial class MainPage : UserControl { |
ObservableCollection<Person> people = new ObservableCollection<Person>(); |
public MainPage() { |
InitializeComponent(); |
people.Add(new Person() {FirstName = "Adam"}); |
people.Add(new Person() { FirstName = "Eve" }); |
this.mainRadTreeView.ItemPrepared += new EventHandler<Telerik.Windows.Controls.RadTreeViewItemPreparedEventArgs>(mainRadTreeView_ItemPrepared); |
this.mainRadTreeView.ItemsSource = this.people; |
} |
void mainRadTreeView_ItemPrepared(object sender, Telerik.Windows.Controls.RadTreeViewItemPreparedEventArgs e) { |
e.PreparedItem.Unloaded += new RoutedEventHandler(PreparedItem_Unloaded); |
} |
void PreparedItem_Unloaded(object sender, RoutedEventArgs e) { |
// This is never handled. |
} |
private void Button_Click(object sender, RoutedEventArgs e) { |
this.people.RemoveAt(this.people.Count-1); |
} |
} |
public class Person { |
public string FirstName { get; set; } |
} |
Help appreciated,
James.