5
我注意到下面的代碼:綁定命令時綁定IsEnabled是否可選?
<Button Content="_Timbres..."
Command="{Binding Path=ShowTimbresCommand}"
IsEnabled="{Binding Path=CanExecuteShowTimbresCommand}"/>
同樣表現爲:
<Button Content="_Timbres..."
Command="{Binding Path=ShowTimbresCommand}">
意思就是說CanExecuteShowTimbresCommand自動綁定到IsEnabled屬性。 這是真的嗎?爲什麼?
謝謝...這意味着我可以刪除大量的XAML代碼。 – 2012-02-19 03:10:41
@MichelKeijzers:如果你到目前爲止總是親自處理'IsEnabled',那確實是這樣。 – 2012-02-19 03:12:04
是的,我目前在任何地方都有一個與IsEnabled = CanExecute相同的命令綁定在一起的命令。我假設你在答案中做的額外編輯是自動完成的。 – 2012-02-19 03:15:10