When is the treeview done checking/unchecking?

6 posts, 1 answers
  1. Anders
    Anders avatar
    80 posts
    Member since:
    Dec 2010

    Posted 06 Jul 2011 Link to this post

    Hi all,

    I have a treeview as outlined below. Whenever an item is checked/unchecked, I 'do something' in the code-behind.

    However, if the user checks the root, all items are checked /unchecked and I get an event for each. I just want to know when it's done so I can inspect the state of the relevant items.

    I can't find a relevant event; even mouseDown doesn't seem to 'fire' in my case?! What could you recommend?

    Thanks for any commments,

    Anders, Denmark

            <Controls1:RadTreeView
                ItemsSource="{Binding Path=Children, NotifyOnSourceUpdated=True}"
                Name="treeview"
                IsLineEnabled="True"
                IsOptionElementsEnabled="True"
                ItemsOptionListType="CheckList"
                IsTriStateMode="True" Checked="treeview_Checked" Unchecked="treeview_Checked">
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 08 Jul 2011 Link to this post

    Hello Anders,

    The Checked event of the RadTreeView fire in the following order when you check a RadTreeViewItem
        1) Children
        2 (optional) Parent if (the clicked is single child)
        3) The item you have clicked
    The way to check the event is fired for the clicked item is:
    private void treeView_Checked(object sender, Telerik.Windows.RadRoutedEventArgs e)
           {
               Debug.WriteLine(e.Source.ToString());
               if ((e as RadTreeViewCheckEventArgs).IsUserInitiated == true)
               {
                               ///Logic after the checked operationn
               }
     
           }
    Let us know if you need further assistance on this.

    All the best,
    Petar Mladenov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for WPF is Visual Studio 2017 Ready
  4. Anders
    Anders avatar
    80 posts
    Member since:
    Dec 2010

    Posted 08 Jul 2011 Link to this post

    Hi Petar,

    Precisely what I was looking for - works like a charm.

    Thanks,
    Anders, Denmark
  5. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 18 Jul 2012 Link to this post

    Hi,

    I want the same behavior but using your example it don't work for me. I'm using IsVirtualization and when I check the parent node it is the first element to rise the checked event.

    Maybe I'm doing something wrong.

    best regards,
    Gonçalo
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 19 Jul 2012 Link to this post

    Hi Goncalo,

     We highly encourage you to open a new support thread with more details on your scenario. This way we would be better able to advice you , furthermore you will receive a faster response.
    Using Virtualization, DataBinging and TriStateMode may lead to various issues. Actually, if you need to bind the CheckedState of the items and use TriState behavior , you  will have to implement your own TriState logic in the ViewModels. This is described in detail in this help article.

    Kind regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 19 Jul 2012 Link to this post

    Sorry. After reading the post with more attention I understood what you mean and used that to accoplish my goals. I already had implemented the ViewModels logic. This is working now. The problem was that if I uncheck a node with the childrens expanded, it happens that before the unchecked event the checked event is rised and the IsUserInitialized flag is true (this what is expected) but then the unchecked event is rised and theres no IsUserInitialized flag set to true. This is because when you uncheck the node with the childrens expanded the checked event is rised when node goes from checked state to indeterminate and after that the uncked event rises.

    I dont know if I was clear about my problem, but I already found a solution and its working. :)

    Thanks,
    Gonçalo
Back to Top
UI for WPF is Visual Studio 2017 Ready