Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3305
How do I set a child node to be selected on Node Expand?
posted

I have a scenario where if a root level node contains 1 child, I need that child to be selected, but I don't see any type of "childNode" collection. I apparently can only set a XamTreeitem to "IsSelected" ==true

but I don't see how to get to it?

  • 3305
    posted

    Never mind I figured it out (for anyone that's interested) the types and Categories are what's loaded into the tree.

      private void treeCatType_ItemExpansionChanged(object sender, ExpansionChangedEventArgs e)
            {
                if (e.IsExpanded)
                {
                    XamTreeItem itm = (XamTreeItem)e.SourceItem;
                    CriteriaSearchCategory cat = (CriteriaSearchCategory)itm.Data;
                    if (cat.SearchTypes.Count==1)
                    {
                        if (itm.HasChildren == true)
                        {
                            CriteriaSearchType type = (CriteriaSearchType)itm.Items[0];
                            ViewModel.SelectedSearchType = type;
                            XamTreeItem curItem = itm.XamTreeItems.First(x => x.Data == type);
                            if (curItem!=null)
                            {
                                curItem.IsSelected = true;
                                curItem.ScrollItemIntoView();
                            }                      
                        }                   
                    }
                    
                }

            }