views:

376

answers:

2

I must be missing something obvious - how can I detect when a node is expanded in a Silverlight TreeView?

A: 

Unfortunately "SelectedItemChanged" is not a routed event yet. So the closest you could get is using this:

treeView.AddHandler(TreeView.MouseLeftButtonUpEvent, new MouseButtonEventHandler(OnMouseLeftButtonUp), true);

    void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        if (e.OriginalSource is Path)
        {
            Path p = e.OriginalSource as Path;
            if (p.Name == "CheckedVisual" || p.Name == "UncheckedVisual")
            {
            }
        }
    }
markti
+1  A: 

Also the treeviewitems have an expanded event which I'm using currently but you'd have to attach to each node you add.

AddHandler t.Expanded, AddressOf TreeViewItem_Expanded
Paully