【发布时间】:2011-07-14 12:39:27
【问题描述】:
像这样:
<Window x:Class="WpfApplication3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ResourceDictionary x:Key=""whatever" Source="colors.xaml" />
<Style TargetType="Button">
<!- button style using colors defined in colors.xaml -->
</Style>
</Window.Resources>
<StackPanel>
<Button Background="{DynamicResource background1}" Height="50"></Button>
<Button Background="{DynamicResource background2}" Height="50"></Button>
</StackPanel>
</Window>
如果我这样做,我会收到有关未解析 background1 和 background2 的警告以及 XamlParseException,因为 window 的 Resource 属性已经定义(它不是)。如果我删除这些东西,一切都很好。
有什么想法吗?
【问题讨论】:
标签: wpf xaml styles resourcedictionary