RibbonGroup - Trigger

Apr 15, 2009 at 4:34 PM

I have been working with the RibbonControl and have been trying to get a Trigger to Show/Collapse a section of the Ribbon using a RibbonGroup. I can't seem to figure out how to make the group use the DependencyProperty that I've created  (IsProjectActive) in the ViewModel so it will make the Visibility either Collapsed or Visible. Here is some simple XAML


<r:RibbonGroup x:Name="ActiveProject" Visibility="Collapsed" >
      <Trigger Property="ViewModel:PenskeRouteAssistViewModel.IsProjectActive" Value="true" >
         <Setter Property="Visibility" Value="Visible"/> 
   <r:RibbonButton Command="{StaticResource ShipmentCommand}" />
   <r:RibbonButton Command="{StaticResource LocationCommand}" />

I get this build error:

Error 37 'Visibility' member is not valid because it does not have a qualifying type name. C:\vRA\product\app\vRA.WPF.UI\Controls\vRARibbonControl.xaml 173 55 vRA.WPF.UI

I've also tried this specifying a TargetName: 



<Trigger Property="ViewModel:PenskeRouteAssistViewModel.IsProjectActive" Value="true" >
   <Setter TargetName="ActiveProject" Property="Visibility" Value="Visible"/>



Same error. I'm sure that I am just doing something stupid but just can't figure it out. Is there something about the RibbonControl that it won't work with a Trigger or am I just completely off base? Please - what am I missing?

thanks in advance!

Jun 3, 2009 at 10:37 AM


Try to specify the control type before Visibility as follows:

<Setter TargetName="ActiveProject" Property="FrameworkElement.Visibility" Value="Visible"/>

Regards Anna :)

Jun 3, 2009 at 12:05 PM

Thanks Anna!!

I'll give that a try... but actually Samantha reminded me that the guidelines state that you shouldn't hide/show ribbon buttons so I now am enabling/disabling them. I would have thought that this would have been easy too but as I found out, changing the state of the CanExecute does not get propagated back to the Ribbon itself even though I set the property changed and do the INotify.. but there may be some other issues since I am using the NonRoutedRibbonCommandDelegate (although I would have thought this would still work).

I do appreciate your taking the time to respond!


Bill :-)