SelectionChanged and MVVM

7 posts, 0 answers
  1. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 23 Jun 2010 Link to this post

    How do i use the SelectionChanged in RadTabControl when using MVVM?
    When I select a TabItem in a RadTabControl, I want to select a specific RadRibbonTab in my RadRibbonBar.
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 23 Jun 2010 Link to this post

    Hi Roy Halvorsen,

    I am not sure that I understand your scenario correctly. Can you please elaborate on it a bit more? Do you need to change the selected tab in a RadRibbonBar depending on the selected item in a TabConrol? If this is the case, a possible approach would be to use the SelectionChanged() event handler of the RadTabControl and insert some custom logic to determine which RibbonBarTab to be selected. For example if the index of the selected tab item determines the selected RibbonBar item, you can do the following:
    private void RadTabControl_SelectionChanged(object sender, RoutedEventArgs e)
    {
        RadTabControl tabControl = sender as RadTabControl;
        if (this.radRibbonBar.Items.Count > tabControl.SelectedIndex)
            (this.radRibbonBar.Items[tabControl.SelectedIndex] as RadRibbonTab).IsSelected = true;
    }
    Is this close to what you had in mind or am I missing something?

    I am looking forward to your reply.

    Regards,
    Tina Stancheva
    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. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 23 Jun 2010 Link to this post

    Yes, you have understood my question correctly, but, I am not using codebehind. I am using MVVM.
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 25 Jun 2010 Link to this post

    Hi Roy Halvorsen,

    Thank you for the clarification. In that case, you can bind the SelectedTab property of the RibbonBar. You can add a converter to define which tab to be selected.

    I prepared a sample project illustrating this approach. Since I am not entirely sure what are the requirements of your scenario, I implemented a scenario in which the SelectedIndex property of the RadTabControl and the SelectedTab property of the RadRibbonBar are data bound to the same property.

    I hope you'll find the example helpful.

    Greetings,
    Tina Stancheva
    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. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 28 Jun 2010 Link to this post

    Since I am using MVVM and no codebehind in the xaml partial class, i guess i have to find a solution using properties in the ViewModel instead. But thanks anyway.
  7. Edu99
    Edu99 avatar
    4 posts
    Member since:
    Oct 2010

    Posted 17 Mar 2011 Link to this post

    Hi Ron, I have a problem with MVVM and SelectionChanged...
  8. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 18 Mar 2011 Link to this post

    Hi Eduardo,

    Can you please elaborate on the issues you have with SelectionChanged and MVVM? What is your scenario and which control do you use - RadRibbonBar or RadTabControl for WPF?

    If you can send us a sample code or a sample project illustrating your case, we will be able to look into the  issues and help you implement your requirements using our controls.

    All the best,
    Tina Stancheva
    the Telerik team
Back to Top
UI for WPF is Visual Studio 2017 Ready