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

SelectionChanged and MVVM

6 Answers 772 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Roy Halvorsen
Top achievements
Rank 1
Roy Halvorsen asked on 23 Jun 2010, 12:02 PM
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.

6 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 23 Jun 2010, 12:53 PM
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
0
Roy Halvorsen
Top achievements
Rank 1
answered on 23 Jun 2010, 12:57 PM
Yes, you have understood my question correctly, but, I am not using codebehind. I am using MVVM.
0
Tina Stancheva
Telerik team
answered on 25 Jun 2010, 03:27 PM
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
0
Roy Halvorsen
Top achievements
Rank 1
answered on 28 Jun 2010, 07:58 AM
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.
0
Edu99
Top achievements
Rank 1
answered on 17 Mar 2011, 10:57 PM
Hi Ron, I have a problem with MVVM and SelectionChanged...
0
Tina Stancheva
Telerik team
answered on 18 Mar 2011, 01:58 PM
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
Tags
TabControl
Asked by
Roy Halvorsen
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Roy Halvorsen
Top achievements
Rank 1
Edu99
Top achievements
Rank 1
Share this question
or