WPF - 为什么Visual Studio在单独的ResourceDictionary中找不到我的样式?



我在App.Resources 中创建并添加了以下ResourceDictionary

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GanttTesting.Views"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<sys:Double x:Key="CommandCenterExpandedTagRatio">1</sys:Double>
<sys:Double x:Key="CommandCenterCollapsedTagRatio">0</sys:Double>
<sys:String x:Key="CommandCenterCollapsedTagRatioAsString">0.1</sys:String>
<sys:Double x:Key="CommandCenterExpandedWidth">330</sys:Double>
<Style x:Key="CommandCenterStyle" TargetType="{x:Type local:CommandCenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Background="Red" Width="100" Height="100"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

然而,当使用";创建新绑定";窗口,并选择";静态资源";,而";CommandCenterExpandedTagRatio";并且其它的String和Double值被正确地显示;CommandCenterStyle;没有出现。手动键入也不起作用
我这里做错什么了吗?非常感谢你的帮助!

注意阅读样式和模板(WPF.NET(以及如何为控件创建样式(WPF.NET(。

<Style x:Key="CommandCenterStyle" TargetType="{x:Type local:CommandCenter}">

这将样式应用于CommandCenter,而不应用于button控件。

本教程可以教您如何创建样式。

相关内容

  • 没有找到相关文章

最新更新