Multiple notifications when item is checked

8 posts, 0 answers
  1. Dieter Schmitz
    Dieter Schmitz avatar
    6 posts
    Member since:
    Dec 2009

    Posted 04 Jan 2010 Link to this post

    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
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 04 Jan 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dieter Schmitz
    Dieter Schmitz avatar
    6 posts
    Member since:
    Dec 2009

    Posted 04 Jan 2010 Link to this post

    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
  5. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 04 Jan 2010 Link to this post

    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.
  6. Dieter Schmitz
    Dieter Schmitz avatar
    6 posts
    Member since:
    Dec 2009

    Posted 08 Jan 2010 Link to this post

    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
  7. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 08 Jan 2010 Link to this post

    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.
  8. Dieter Schmitz
    Dieter Schmitz avatar
    6 posts
    Member since:
    Dec 2009

    Posted 08 Jan 2010 Link to this post

    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?
  9. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 08 Jan 2010 Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready