I am finding it surprisingly hard to find examples of binding the visibility of a RibbonContextualTabGroup. I have a property in my code-behind that should decide when to display a ribbon tab, but everything I've tried so far has no effect. My code-behind is essentially:
public partial class MainWindow : RibbonWindow
{
public string Port { get; set; }
}
A summary of my WPF code is below. I'm looking for a solution that binds the Visibility
property to whether or not MainWindow.Port
is null
.
<ribbon:RibbonWindow
...
xmlns:src="clr-namespace:MagExplorer" />
...
<ribbon:RibbonTab x:Name="COMTab"
Header="COM"
ContextualTabGroupHeader="Communications">
...
</ribbon:RibbonTab>
<ribbon:Ribbon.ContextualTabGroups>
<ribbon:RibbonContextualTabGroup Header="Communications"
Visibility="<What goes here?>" />
</ribbon:Ribbon.ContextualTabGroups>
You can create a Converter IsNotNullToVisibilityConverter
with the Convert method like this:
And then put it in your XAML
In your code behind: