Hi,
I have a ribbon button in a WPF Desktop program that displays an 'unread messages' indicator in the top right corner, like what you get on a smartphone, but when that button is added to the Quick Access Toolbar, the indicator is shown as well and overwrites the whole icon because it's using the small icon.
I want to disable the indicator when the button is in the QAT but show it when the button is in the ribbon, but have been unable to work out how to do it and was hoping you could provide some guidance.
Here is the xaml for this button. The OverlayBadgeBehavior is a 'Behavior' class used to draw the badge with a number in a circle. The badge can be hidden by setting its IsEnabled property to false, which I do when there are no unprocessed notifications. I also use a different icon (different color) when there are unprocessed notifications.
<ribbon:Button x:Uid="_notificationsButton"
x:Name="_notificationsButton"
Command="{Binding Path=ViewNotificationsCommand}"
Label="Notifications"
ScreenTipDescription="View notifications."
commonBehaviors:OverlayBadgeBehavior.Value="{Binding Path=UnprocessedNotificationCount}"
commonBehaviors:OverlayBadgeBehavior.IsEnabled="{Binding Path=HasUnprocessedNotifications}">
<ribbon:Button.Style>
<Style x:Uid="_notificationsButtonStyle"
TargetType="ribbon:Button">
<Style.Triggers>
<DataTrigger x:Uid="_dataTrigger_1" Binding="{Binding Path=HasUnprocessedNotifications}" Value="False">
<Setter x:Uid="_setter_11"
Property="ImageSourceLarge"
Value="{DynamicResource icoNotifications32Image}" />
<Setter x:Uid="_setter_12"
Property="ImageSourceSmall"
Value="{DynamicResource icoNotifications16Image}" />
</DataTrigger>
<DataTrigger x:Uid="_dataTrigger_2" Binding="{Binding Path=HasUnprocessedNotifications}" Value="True">
<Setter x:Uid="_setter_21"
Property="ImageSourceLarge"
Value="{DynamicResource icoNotificationsUnread32Image}" />
<Setter x:Uid="_setter_22"
Property="ImageSourceSmall"
Value="{DynamicResource icoNotificationsUnread16Image}" />
</DataTrigger>
<Trigger x:Uid="_dataTrigger_3" Property="Context" Value="QuickAccessToolBarItem">
<Setter x:Uid="_setter_23"
Property="commonBehaviors:OverlayBadgeBehavior.IsEnabled"
Value="False" />
</Trigger>
</Style.Triggers>
</Style>
</ribbon:Button.Style>
</ribbon:Button>
As you can see, I have tried to set OverlayBadgeBehavior.IsEnabled to false when the button's Context property is set to "QuickAccessToolBarItem", but it doesn't work.
I have also tried using the button's VariantSize property is set to "Small", but that also doesn't work.
I have also tried using a DataTrigger instead of a regular Trigger, with both of these properties (one at a time, of course), but that doesn't work either.
Note that the OverlayBadgeBehavior class is written as a general-use behavior that can applied to any control, and does not "know" about RibbonButtons or any other specific control, so I would be reluctant to introduce control-specific logic by checking non-standard properties like VariantSize or Context.
Ideally, I would prefer a xaml-only solution, but I'm happy to implement it in whatever manner is necessary (code-behind, etc.).
Thanks in advance.