Node is selected but not highlighted

6 posts, 1 answers
  1. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 09 Nov 2010 Link to this post

    I have a Treeview that is bound to a list.  I am using a containerbinding to set IsExpanded and IsSelected.  I set the property for IsSelected to True on one of my items.

    After setting the itemssource of the treeview, the correct item is selected - but it is not highlighted. i.e. there is a light gray border around the item, but it does not have the yellow background color that you get when you click on a node.  So it seems the node is selected, but is not active.  How do I get the node to be highlighted?

    Thanks,
    Justin
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 10 Nov 2010 Link to this post

    Hello Justin Lee,

    It appears that the Silverlight Application isn't focused initially. Therefore, you have to manually focus it like so:

    private void UserControl_Loaded(object sender, RoutedEventArgs e)
           {
               System.Windows.Browser.HtmlPage.Plugin.Focus();
           }

    I`ve prepared a sample project demonstrating a binding to the IsSelected RadTreeViewItem property with ContainerBindings and the mentioned "tricky" code. Please examine it and let me know if it satisfies you.

    Best wishes,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Bala
    Bala avatar
    20 posts
    Member since:
    Dec 2011

    Posted 19 Mar 2012 Link to this post

    hi ,



     Is there option to Highlight  a node text  in tree view programatically .? with radtreeview ?




    sbala
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 19 Mar 2012 Link to this post

    Hello Bala,

     Usually, playing with focus in Silverlight is tricky. However, there are cases in which you are able to focus a UIElement successfully. You can get a particular RadTreeViewItem in various ways:

    1) If it is defined in XAML and has x:Name - access it with this.itsXName
    2) If it is generated after binding - use RadTreeView.ItemContainerGenerator.ContainerFromItem() or ContainerFromIndex() methods
    3) If it is generated after binding, and you know the Path to it - use RadTreeView.GetItemByPath(string path)

    Once you have accessed the RadTreeViewItem, you can try calling its Focus() method.
    Please let us know if this helped you.

    Greetings,
    Petar Mladenov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. Bala
    Bala avatar
    20 posts
    Member since:
    Dec 2011

    Posted 20 Mar 2012 Link to this post

    Hi  Petar Mladenov,


      i'm not able to highlight the expanded node and i used binding source from sql . after binding the source. while i search for a particular node i m able to epand the node but couldn't highlight the text.
     i tried
    Ex:
    string path = "RootNode\\ParentNode"

    radtv.ExpandItemByPath(path,

     

    "|");

     

    radtv.GetItemByPath(path,

     

    "|");

     

    radtv.Focus();


    But this doesn't work, am i making any mistake in this ?


    Plz provide the solution for this.
    i tried in xml as datasource too .i have the same isuue in that too.(Highlighting the Text).


    if possible make static treeview sample example with highlighting text property.

    Looking for the Solz,
    Balas

  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 23 Mar 2012 Link to this post

    Hello Bala,

     I hope the answers in these post have helped you. Please let us know if you need further assistance.
    Bind RadTreeView To XML
    Multiple Tree Nodes remain Highlighted

    Regards,
    Petar Mladenov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
DevCraft banner