2013-12-15 150 views
0

我目前正在使用功能区框架为WPF展开功能区。禁用功能区按钮

我已经看到,在办公室里有一个“禁用按钮”,一旦条件满足就会“激活”。

有没有人有一个想法如何实现这样的功能?

此外,请注意标记“位置”功能区按钮的红色框左侧的“文本框”,是否有扩展功能区文本框以获得“向上箭头和向下箭头”按钮以增加数字“+1 “和 ”-1“

enter image description here

最好的问候!

回答

0

当您将ICommand实例绑定到RibbonButton.Command属性时,可以通过将bool条件添加到ICommand.CanExecute method中来禁用和启用该按钮。当条件返回true时,RibbonButton将被启用,当它返回false时,它将被禁用。

在XAML:

<Ribbon:RibbonButton Command="{Binding Activate, Mode=OneWay}" Label="Activate" ... /> 

在代码(使用的RelayCommand一种形式):

public ICommand Activate 
{ 
    get { return new ActionCommand(action => ActivateCommand(), 
canExecute => CanActivate()); } // output of CanActivate will enable/disable button 
}