This is a migrated thread and some comments may be shown as answers.

When is the treeview done checking/unchecking?

5 Answers 112 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 06 Jul 2011, 09:18 AM
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">

5 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 08 Jul 2011, 04:14 PM
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!

0
Anders
Top achievements
Rank 1
answered on 08 Jul 2011, 07:43 PM
Hi Petar,

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

Thanks,
Anders, Denmark
0
Pedro
Top achievements
Rank 1
answered on 18 Jul 2012, 11:43 AM
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
0
Petar Mladenov
Telerik team
answered on 19 Jul 2012, 07:14 AM
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.

0
Pedro
Top achievements
Rank 1
answered on 19 Jul 2012, 09:01 AM
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
Tags
TreeView
Asked by
Anders
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Anders
Top achievements
Rank 1
Pedro
Top achievements
Rank 1
Share this question
or