gpt4 book ai didi

WPF 切换开关 : how to add Win 10 style

转载 作者:行者123 更新时间:2023-12-04 00:35:57 26 4
gpt4 key购买 nike

我找到了这个款式here并将其添加到我的 Window.Resources 中:

<Style x:Key="Custom.ToggleSwitch.Win10"
BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}"
TargetType="{x:Type Controls:ToggleSwitch}">
<Setter Property="Padding" Value="0 0 10 0" />
<Style.Triggers>
<Trigger Property="ContentDirection" Value="RightToLeft">
<Setter Property="Padding" Value="10 0 0 0" />
</Trigger>
</Style.Triggers>
</Style>

问题是这一行:

BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" 

出现错误:

Error 103 The resource "MahApps.Metro.Styles.ToggleSwitch.Win10" could not be resolved.

有什么建议吗?

最佳答案

使用 NuGet(工具->NuGet 包管理器->Visual Studio 中的包管理器控制台)安装 MahApps:http://mahapps.com/guides/quick-start.html

并将 Styles/Controls.ToggleSwitch.xaml 资源字典合并到:

<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ToggleSwitch.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="Custom.ToggleSwitch.Win10"
BasedOn="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}"
TargetType="{x:Type Controls:ToggleSwitch}">
<Setter Property="Padding" Value="0 0 10 0" />
<Style.Triggers>
<Trigger Property="ContentDirection" Value="RightToLeft">
<Setter Property="Padding" Value="10 0 0 0" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</Window.Resources>

关于WPF 切换开关 : how to add Win 10 style,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42760995/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com