I have a WPF ribbon application using Microsoft.Windows.Controls.Ribbon
. I can set the view through the Grid.Row
tag:
</ribbon:Ribbon>
<Grid Grid.Row="1">
<!-- View's content here -->
</Grid>
</Grid>
</ribbon:RibbonWindow>
Q: How can I change the view depending on the selected ribbon tab?
You have a few options.
SelectionChanged
event and trade out your view's content. If you're using Prism, you could probably create a SelectorRegionAdapter
to do this for you.Ribbon.SelectedValue
(setting SelectedValuePath
to say Label
) and provide a DataTrigger
which handles each of your tab's names.You could put an instance of each view model (assuming your RibbonWindow
s data context has each of the view models you need) you care about in the RibbonTab.Tag
property, and adapt your view based on SelectedItem.Tag
:
<r:Ribbon x:Name="PART_Ribbon" ...>
<r:RibbonTab Tag="{Binding HomeViewModel}" ... />
</r:Ribbon>
<Grid>
<ContentControl Content="{Binding SelectedItem.Tag,
ElementName=PART_Ribbon}" />
</Grid>