2013-12-15 146 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 
}