Sync between RadTreeView and RadCarousel

6 posts, 1 answers
  1. Vien Nguyen
    Vien Nguyen avatar
    8 posts
    Member since:
    Jul 2007

    Posted 27 May 2011 Link to this post

    I am using both a RadTreeView and a RadCarousel and bind the root nodes of the tree view and the carousel to the same list of items. If the user change the selection on one control, I would like the app to automaticall change the selected item on the other control. I tried to bind the SelectedItem property on both control to the same object but that did work. Has anyone tried this before?  Thanks.
  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 30 May 2011 Link to this post

    Hi Vien Nguyen,

    You may bind the SelectedItem of both the RadCarousel and RadTreeView to a property in your ViewModel for example:

    <telerik:RadTreeView x:Name="treeView" ItemsSource="{Binding Clubs}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" />
            <telerik:RadCarousel x:Name="carousel" ItemsSource="{Binding Clubs}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" Grid.Row="1" />

    However, this will be applicable only if the item you want to select from the TreeView is visible in the RadCarousel. Otherwise, you may handle the SelectionChanged event of the TreeView and set the selected item of the Carousel:
    private void treeView_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                foreach (var item in e.AddedItems)
                {
                    this.carousel.BringDataItemIntoView(item);
                    this.carousel.SelectedItem = item;
                }
            }

    Do let me know whether the suggested approach fits into your requirements.
     

    Regards,
    Maya
    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. UI for WPF is Visual Studio 2017 Ready
  4. Vien Nguyen
    Vien Nguyen avatar
    8 posts
    Member since:
    Jul 2007

    Posted 31 May 2011 Link to this post

    Still doesnt work.
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 31 May 2011 Link to this post

    Hi Vien Nguyen,

    I am sending you the sample project I created for the case. Please take a look at it and let me know if it differs from your settings and requirements. If needed, feel free to change it in the way you want and send it back so that I can seed your particular scenario.
     

    All the best,
    Maya
    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
  6. Vien Nguyen
    Vien Nguyen avatar
    8 posts
    Member since:
    Jul 2007

    Posted 02 Jun 2011 Link to this post

    Thanks for the example. It works when selection on the tree is changed. How do I make it so that scrolling through the carousel also scroll through the tree. Thanks.
  7. Vien Nguyen
    Vien Nguyen avatar
    8 posts
    Member since:
    Jul 2007

    Posted 02 Jun 2011 Link to this post

    I got it to work now. Thank you.
Back to Top
UI for WPF is Visual Studio 2017 Ready