【发布时间】:2011-09-03 15:28:15
【问题描述】:
我在 ResourceDictionary 中定义我的设置和样式:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:properties="clr-namespace:Kavand.UI.Properties">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<properties:Settings x:Key="settings" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="PopupMenu_StackPanel">
<Setter Property="TextBlock.FontSize" Value="{Binding Source={StaticResource settings}, Path=Default.Font_Menu_Size}" />
<Setter Property="TextBlock.FontFamily" Value="{Binding Source={StaticResource settings}, Path=Default.Font_Menu_Family}" />
<Setter Property="TextBlock.FontWeight" Value="{Binding Source={StaticResource settings}, Path=Default.Font_Menu_Weight}" />
<Style.Resources>
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource KavandMenuItem}">
<Style.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="IsEnabled" Value="false" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True" />
<Condition Property="IsHighlighted" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{DynamicResource K_Brush_Gray}" />
</MultiTrigger>
</Style.Triggers>
</Style>
</Style.Resources>
</Style>
</ResourceDictionary>
当我运行我的应用程序时,我得到了错误:
'无法创建未知类型 '{clr-命名空间:Kavand.UI.Properties}设置'。' 行号“6”和行位置 '14'。
【问题讨论】:
-
是编译错误还是运行时错误?删除前三个 setter 是否允许应用程序运行?
-
这是一个运行时错误,不,当我删除包含定义的部分时,应用程序将被编译
标签: wpf xaml styles application-settings wpf-style