Dictionary 来自资源字典的样式

Dictionary 来自资源字典的样式,dictionary,combobox,resources,styles,staticresource,Dictionary,Combobox,Resources,Styles,Staticresource,我创建了一个资源字典,其中包含组合框的控件模板。我已经使用XamlWriter提取了默认的combobox控件模板,并将该代码粘贴到我正在处理的这个资源字典中。只是研究我对控件模板的修改如何反映到控件本身。文件名为Dictionary1.xaml 是否可以在测试应用程序的每个组合框中使用该控件模板,而不在Xaml的每个组合框中键入它?我通常会设置combobox的样式=“{StaticResource ComboboxTesting}”,但如果我的更改能够反映到测试应用程序中的每个combox,

我创建了一个资源字典,其中包含组合框的控件模板。我已经使用XamlWriter提取了默认的combobox控件模板,并将该代码粘贴到我正在处理的这个资源字典中。只是研究我对控件模板的修改如何反映到控件本身。文件名为Dictionary1.xaml

是否可以在测试应用程序的每个组合框中使用该控件模板,而不在Xaml的每个组合框中键入它?我通常会设置combobox的样式=“{StaticResource ComboboxTesting}”,但如果我的更改能够反映到测试应用程序中的每个combox,那就太好了。“ComboboxTesting”是我的资源字典中的关键

我已经提出了这段代码,但它自然不起作用,因为我不知道在Setter.Value标记之间放置什么

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Dictionary1.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    <Style TargetType="ComboBox">
        <Setter Property="Style">
            <Setter.Value>
                <!-- Something here... -->
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>

谢谢


J.

尝试将setter属性更改为除“style”之外的任何内容,尝试将其更改为高度、宽度、颜色、字体或除style以外的任何内容。。。。可能是因为您从children setter更改了父样式…

请尝试此操作

<Window.Resources>
<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Dictionary1.xaml" />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<Style TargetType="ComboBox">
    <Setter Property="Background">
        <Setter.Value>
            <!-- Something here... -->
        </Setter.Value>
    </Setter>
</Style>