ContextMenu disabled when using PopupButton in StatusBar

Ribbon for WPF Forum

Posted 15 years ago by LaurentB - Intersystems
Avatar
Hello,
I use a ContextMenu in PopupButton in a StatusBar

<ribbon:RibbonWindow.StatusBar>
.....
<StatusBarItem Grid.Column="4" Padding="3,0,0,0" >
<shared:PopupButton x:Name="popupButtonMenuXAML" Content="Style"
Margin="5" HorizontalAlignment="Center"
IsTransparencyModeEnabled="True"
HasDropShadow="True">
<shared:PopupButton.PopupMenu>
<ContextMenu>
<ribbon:Button Command="local:ApplicationCommands.ApplicationStyleOffice2007Blue" />
<ribbon:Button Command="local:ApplicationCommands.ApplicationOffice2007Black" />
<ribbon:Button Command="local:ApplicationCommands.ApplicationOffice2007Grey" />
</ContextMenu>
</shared:PopupButton.PopupMenu>
</shared:PopupButton>
</StatusBarItem>
</StatusBar>

When I open the ContextMenu, all the menus are disabled.
Where is the problem ?

Thanks

[Modified at 02/10/2009 11:05 AM]

Comments (3)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Chances are that this is related to the way WPF routes commands. You can verify this by doing a couple simple tests:

1. If you set the Command property of the PopupButton itself to one of your ApplicationCommands, does the PopupButton disable? If so, then the commands are probalby not be routed correctly to your handlers (CanExecute/Execute).

2. If the PopupButton is not disabled when you set the Command, then try replacing the ribbon:Button elements with the WPF MenuItem.

Please let us know the results of these two tests, so we can narrow the problem down.


Actipro Software Support

Posted 15 years ago by LaurentB - Intersystems
Avatar
Hello, I found the solution bt using this declaration :

<ribbon:Button Command="local:ApplicationCommands.ApplicationStyleOffice2007Blue" CommandTarget="{Binding Mode=OneWay, Path=PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}" />

See http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/7bd75a7c-eab4-4f3a-967b-94a9534a7455

Thanks

[Modified at 02/11/2009 05:59 AM]
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
As long as you ensure focus is kept in the main focus scope you probably don't need the binding. But the binding works too to help ensure against that scenario.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.