Separator casuses CanExecute bug

Ribbon for WPF Forum

Posted 11 years ago by Owen Christensen - Software Engineer, Minitab Inc.
Version: 4.5.0484
Avatar
System: .NET 3.5, Windows Vista, 64-bit

<Window x:Class="WpfApplication3.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
    Title="Window1" WindowState="Maximized">
    <Window.Resources>
        <ribbon:RibbonCommand x:Key="ChangeAlignmentCommand" Label="CommandLabel"/>
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="{StaticResource ChangeAlignmentCommand}" CanExecute="CommandBinding_CanExecute"/>
    </Window.CommandBindings>
    <ribbon:Ribbon>
        <ribbon:Tab>
            <ribbon:Group>
                <ribbon:PopupButton Label="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled}">
                    <ribbon:Menu>
                        <ribbon:Button Command="{StaticResource ChangeAlignmentCommand}" CommandParameter="Left" Label="Left"/>
                        <!--<ribbon:Separator/>-->
                        <ribbon:Button Command="{StaticResource ChangeAlignmentCommand}" CommandParameter="Top" Label="Top"/>
                    </ribbon:Menu>
                </ribbon:PopupButton>
            </ribbon:Group>
        </ribbon:Tab>
    </ribbon:Ribbon>
</Window>

  private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
  {
    e.CanExecute = false;
  }
If you run the above window as given the PopupButton is disabled as expected; all child buttons cannot execute so the parent should not be enabled.
However, uncomment the Separator and the PopupButton becomes enabled. This is _always_ true, regardless of the state of any children and incorrect.

Comments (1)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Owen,

Good catch, we'll get this resolved for the next maintenance release.


Actipro Software Support

The latest build of this product (v2019.1 build 0685) was released 12 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.