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

Multiple notifications when item is checked

7 Answers 108 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Dieter Schmitz
Top achievements
Rank 1
Dieter Schmitz asked on 04 Jan 2010, 01:42 PM
Hi,

I've created a treeview which has the TriStateMode enabled and defined a callback function when an item were checked/unchecked.

My problem is that I get notified multiple times if a subitem was checked. The first notification is for the top element, and the next notification is for the top level's child element and so on... The last notification is the checked item itself.

Is there a way to determine the item which was checked?

Thanks
Dieter

7 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 04 Jan 2010, 01:49 PM
Hello Dieter Schmitz,

This is beacause the events are RoutedEvents, You can check the OriginalSource property of the event args to see which is the item.

Best wishes,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dieter Schmitz
Top achievements
Rank 1
answered on 04 Jan 2010, 03:03 PM
Hi Valentin,

thanks for your quick answer.

Sorry, but I cannot find the correct property within OriginalSource. Could you please give me a hint?

Thanks
Dieter
0
Valentin.Stoychev
Telerik team
answered on 04 Jan 2010, 05:05 PM
Hello Dieter Schmitz,

Please check the following code:

XAML:
<telerikNavigation:RadTreeView IsOptionElementsEnabled="True" Checked="RadTreeView_Checked">
            <telerikNavigation:RadTreeViewItem Header="Item1">
                <telerikNavigation:RadTreeViewItem Header="Item2"/>
            </telerikNavigation:RadTreeViewItem>
</telerikNavigation:RadTreeView>

Code Behind:
private void RadTreeView_Checked(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    RadTreeViewItem original = e.OriginalSource as RadTreeViewItem;
}

Sincerely yours,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dieter Schmitz
Top achievements
Rank 1
answered on 08 Jan 2010, 08:02 AM
Hi Valentin,

I implemented the code from your last answer.
If I check a subitem, every property of the the OriginalSource property changed with every notification and I am not able to find the correct property within OriginalSource which defines the item, which was clicked initially :-(

I may have been unclear.

Example tree:
- Root item
| - SubItem1
| | - Subitem 2

If SubItem1 is checked, I get 3 notifications. One for SubItem1, one for SubItem2 and the last for Root Item.
How can I find out, that SubItem1 was clicked initially, even I am in the notification of root item?

Cheers
Dieter
0
Valentin.Stoychev
Telerik team
answered on 08 Jan 2010, 01:56 PM
Hello Dieter Schmitz,

Yes - you will not be able to get the node that was clicked by the user.

Can you give us more info on what is your senario and why you need this?

Regards,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dieter Schmitz
Top achievements
Rank 1
answered on 08 Jan 2010, 02:23 PM
My GUI is defined as follows:
On the left side a treeview and on the right side a list box is placed.
The tree view is filled like the windows explorer: with directories and files.

What I need:
If the user checks a treeview node, all sub items must be checked too, and the checked item must be added to the list box.
It is not neccessary that the parent items were checked automatically by the tree view.
But it is essential that only the checked node is added to the list box.

Do you need further information?
0
Valentin.Stoychev
Telerik team
answered on 08 Jan 2010, 02:34 PM
Hi Dieter Schmitz,

I understand... - It is a valid scenario. We will see how to improve the API so we can set a flag to the node that initiated the events.

for the moment I recommend you to turn off the tri state mode and to check the child items manually when a parent is checked.

I added 1000 Telerik points to your account and added this scenario as a backlog item.

Let us know if you need more help.

Best wishes,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
Dieter Schmitz
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Dieter Schmitz
Top achievements
Rank 1
Share this question
or