【问题标题】:MahApps ToggleSwitch not found in version 2.0 in .Net Core 3.1在 .Net Core 3.1 的 2.0 版中找不到 MahApps ToggleSwitch
【发布时间】:2020-04-23 02:55:34
【问题描述】:

我正在为 wpf-mvvm netcoreapp3.1 应用程序使用最新版本的 MahApps.Metro。我从 wpf-mvvm .netframework4.7 应用程序迁移了 mvvm 应用程序。我以前为 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 控件的 CheckedCommandUnCheckedCommand 参数不再存在,我找不到合适的替代品。任何帮助将不胜感激。

【问题讨论】:

    标签: c# wpf-controls mahapps.metro .net-core-3.1


    【解决方案1】:

    感谢@punker76 在拉取请求#3785 中向MahApps.Metro 添加了两个属性,此问题已得到解决

    <Controls:ToggleSwitch CommandParameter="{Binding}"
                       OnCommand="{Binding ToggleSwitchOnCommand}"
                       OffCommand="{Binding ToggleSwitchOffCommand}" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-10
      • 1970-01-01
      • 2021-01-24
      • 1970-01-01
      • 2020-12-03
      • 2021-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多