我目前正在使用MahApps地鐵庫對我的舊版wpf應用程序的外觀進行擺弄。我與卡住控制:ToggleSwitch我可以綁定幾乎所有的東西,但命令。 當我嘗試綁定如下命令,Metro風格的Windows 7 WPF應用程序-toggleSwitch-
<Controls:ToggleSwitch Header="Start Playing" OnLabel="Stop" OffLabel="Play"
IsChecked="{Binding ToggleRecordCommand}"
CommandParameter="{Binding}" />
我得到一個錯誤等;
Error 62 A TwoWay or OneWayToSource binding cannot work on the read-only property 'ToggleRecordCommand' of type 'RecorderApp.View.MainWindowViewModel'.
而且它告訴我沒有CommandParameter。我如何將動作綁定到這個?
爲了使用CommandParameter您必須指定命令whick我認爲將在被點擊的事件引發不布爾器isChecked財產 – iltzortz
通常情況下,我可以綁定命令按鈕。但是切換開關不可能嗎?我曾計劃在視圖模型 – mechanicum