Hi,
We are using your ContextMenu class with Button as the menu item object. Each button has its Command property set to a RibbonCommand. For some menu items, the label is dynamic and sensitive to the current selection. We change the label in the CanExecute handler for the menu item. The problem we are seeing is that the Button whose command's label property we are changing is not updating its layout, causing the text to get cut off. We are trying to force the context menu to update its layout, but no luck. Here is the CanExecute event handler:Here is the context menu xaml snippet:
Any ideas? Thanks!
Sean
We are using your ContextMenu class with Button as the menu item object. Each button has its Command property set to a RibbonCommand. For some menu items, the label is dynamic and sensitive to the current selection. We change the label in the CanExecute handler for the menu item. The problem we are seeing is that the Button whose command's label property we are changing is not updating its layout, causing the text to get cut off. We are trying to force the context menu to update its layout, but no luck. Here is the CanExecute event handler:
private void CanExecuteEventHandler(object sender, CanExecuteRoutedEventArgs e)
{
RibbonCommand command = e.Command as RibbonCommand;
if (command != null)
{
if (e.CanExecute == false)
{
command.Label = PresenterStrings.SetAsDefault;
}
else
{
if (Flowchart.Selection.Shapes.Count() == 1)
{
command.Label = GetDynamicLabel();
_contextMenu.InvalidateMeasure();
}
}
}
}
<ribbon:Menu x:Name="_contextMenu">
<ribbon:PopupButton Label="Format">
<ribbon:Menu x:Name="_formatMenu">
<ribbon:Button Command="{StaticResource SaveStyleAsCommand}"/>
<ribbon:Button Command="{StaticResource SetAsDefaultStyleCommand}" x:Name="_formatMenuItem" />
</ribbon:Menu>
</ribbon:PopupButton>
</ribbon:Menu>
Sean