。Net Core 3.1版本2.0中找不到MahApps ToggleSwitch属性

问题描述 投票:0回答:2

我创建了一个新的.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

wpf .net-core mahapps.metro
2个回答
0
投票

根据ToggleSwitch来源,应使用ToggleSwitch属性而不是IsOn

IsChecked

0
投票

[<mah:ToggleSwitch Header="WiFi rest state" IsOn="True"/> 中的属性称为IsOn

[2.0.0-alpha0748OffLabel分别是OnLabelOffContentOnContentIsCheckedChanged

© www.soinside.com 2019 - 2024. All rights reserved.