WPF Ribbon Tab view in Designer

2019-06-18 07:31发布

问题:

I'm using "Microsoft Ribbon for WPF" and creating multiple RibbonTab. I cannot figure out a way to view/focus different tabs in the designer and it by default show the "Home" tab. To see design/xaml changes I made to tabs other than the "Home" tab, I have to debug the project every time and click through the tabs, which is not very convenient. Or I can command out the tab xaml I want to to ignore. Anyone body out there has a solution?

回答1:

You can also use the SelectedIndex property on the Ribbon to set which tab is the currently selected tab (0 being the first tab, 1 being the second, etc.)

<ribbon:Ribbon SelectedIndex="0" />


回答2:

The only way I have found is to set the Selector.IsSelected property to true. This will cause the tab to become visible at design time.

<ribbon:RibbonTab Selector.IsSelected="True" ...


回答3:

I can't confirm this is working right now because my preview in general is not working properly, but this works in general in WPF when trying to hide something at design time only.

Include the namespace for blend

xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 

Then in the element you want to hide use d:IsHidden="True". This will only affect design time, which eliminates the problem of forgetting to change the selected index to the correct value before building.