PopupButton not disabled when generated by DataTemplate

Ribbon for WPF Forum

Posted 13 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Version: 11.1.0543
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar
Hi,
I am trying to use databinding to dynamically generate the controls on my ribbon. I have found a problem where a PopupButton doesn't get automatically disabled when its PopupContent is set to a Menu which has an an ItemsSource binding and an ItemTemplate.

E.g.

<r:PopupButton Label="Bound" Command="NotACommand">
  <r:Menu ItemsSource="{Binding Items}">
    <r:Menu.ItemTemplate>
      <DataTemplate>
        <r:Button Context="MenuItem" Label="{Binding}" />
      </DataTemplate>
    </r:Menu.ItemTemplate>
  </r:Menu>
</r:PopupButton> 
I have emailed a sample showing the problem to support.

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Phil,

In that scenario the visuals can't be found since they are dynamically created so we can't check them like we can in the scenario where you explicitly give the controls as popup children. As a workaround, you can give another Command (instead of NotACommand) and have that command's CanExecute return true/false based on the state of the commands on your buttons.


Actipro Software Support

Posted 13 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Avatar
Thanks, that works great. Is there any way the command on a PopupButton can be executed, or does it only use CanExecute?
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Phil,

I believe it will fire that command when the popup is first opening from a click. But you should really only use the command for a PopupButton to control its enabled state.


Actipro Software Support

The latest build of this product (v24.1.2) was released 7 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.