我正在为一个wpf-mvvm netcoreapp3.1应用程序使用最新版本的MahApps.Metro。我把mvvm应用从wpf-mvvm.netframework4.7应用迁移过来。我之前的wpf-mvvm .netframework4.7应用有以下内容。
<mahapps:ToggleSwitch OnLabel="{Binding OnLabelText}"
OffLabel="{Binding OffLabelText}"
CheckedCommand="{Binding StartDistributionCommand}"
UnCheckedCommand="{Binding StopDistributionCommand}"
Style="{StaticResource ToggleSwitch.Win10}"
IsChecked="{Binding WebDistributionOnStatus, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
wpf .netcoreapp3.1的更新版本是:
<mahapps:ToggleSwitch OnContent="{Binding OnLabelText}"
OffContent="{Binding OffLabelText}"
CheckedCommand="{Binding StartDistributionCommand}"
UnCheckedCommand="{Binding StopDistributionCommand}"
Style="{StaticResource ToggleSwitch.Win10}"
IsOn="{Binding WebDistributionOnStatus, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
问题是... 检查命令 和 未选中的命令 ToggleSwitch控件的参数已不存在,我找不到合适的替代品。任何帮助将被感激。
这个问题已经解决了,这要感谢 @punker76 给我添加了两个属性。MahApps.Metro 在拉请求 #3785
<Controls:ToggleSwitch CommandParameter="{Binding}"
OnCommand="{Binding ToggleSwitchOnCommand}"
OffCommand="{Binding ToggleSwitchOffCommand}" />