wpf - 在 .Net Core 3.1 的 2.0 版中找不到 MahApps ToggleSwitch 属性

标签 wpf .net-core mahapps.metro

我创建了一个新的 .Net Core 3.1 WPF 应用程序。 我为 MahApps.Metro v 2.0.0-alpha0748 添加 nuget 包

我向 xaml 添加了一个切换开关

<Window x:Class="WpfTestSandbox.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfTestSandbox"
    xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800">
    <Grid>
        <mah:ToggleSwitch Header="WiFi rest state"
            Ischecked="True" />
    </Grid>
</Window>

这是我的App.xaml

<Application x:Class="WpfTestSandbox.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:WpfTestSandbox"
         StartupUri="MainWindow.xaml">
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
            <!-- Accent and AppTheme setting -->
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/dark.green.xaml" />
            <ResourceDictionary>
                <SolidColorBrush x:Key="{x:Static SystemColors.WindowTextBrushKey}" Color="White"/>
            </ResourceDictionary>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary> 
</Application.Resources>
</Application>

IsChecked 被标记为在 ToggleSwitch 类型中找不到。

其他属性也未找到... OffLabel、OnLabel、IsCheckedChanged,...

我是否缺少依赖项?

TIA

最佳答案

该属性在 2.0.0-alpha0748 中称为 IsOn

OffLabelOnLabel 分别为 OffContentOnContentIsCheckedChanged已切换

关于wpf - 在 .Net Core 3.1 的 2.0 版中找不到 MahApps ToggleSwitch 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60832386/

相关文章:

asp.net-core - 使用具有目标框架名称(如 #if !NETSTANDARD1_6)的代码编译 netcoreapp1.0

c# - 将行为附加到 MetroWindow 失败并导致错误的样式

wpf - 寻找一些 WPF 布局建议

wpf - 表面开发: Translate/Rotate/Scale items without ScatterView

c# - 无法下载 Azure Blob 进行流式传输

.net-core - 你如何通过 "dotnet test"的特征过滤 xunit 测试?

c# - 窗口和任务栏的不同图标

c# - 显示/隐藏 Mahapps 弹出控件

wpf - 包含表面交互元素的 ScatterViewItems

c# - 如果窗口的所有者是通过 WindowInteropHelper 设置的,如何获取窗口的所有者?