gpt4 book ai didi

c# - 如何创建 'Private' ResourceDictionary?

转载 作者:太空宇宙 更新时间:2023-11-03 14:11:22 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to make a Style that only exists within the context of a ResourceDictionary

我正在构建一个复杂的 ResourceDictionary,它将公开我想与包含该 ResourceDictionary 的项目共享的 ControlTemplate。但是,此 ResourceDictionary 包含一系列我希望项目可用的支持样式和模板。我该怎么做?

例如:

<ResourceDictionary>
<!-- Private dictionary items used to set up the publicly usable Omnibox templates -->
<ResourceDictionary x:Key="PrivateDictionary">
<Thickness x:Key="BaseValueMarginAdjustment">2,0,0,0</Thickness>
<!--Base Styles -->
<Style x:Key="BaseElement" TargetType="FrameworkElement">...</Style>
<Style x:Key="GridStyle" TargetType="Grid" BasedOn="{StaticResource BaseElement}">...</Style>
<Style TargetType="Selector" x:Key="SelectorStyle" BasedOn="{StaticResource BaseElement}">...</Style>
...
</ResourceDictionary>
<!--Public CONTROL TEMPLATES -->
<ControlTemplate TargetType="{x:Type local:OmniBox}" x:Key="OBListBoxTemplate">
<Grid x:Name="PART_Grid" Style="{StaticResource GridStyle}">
<ListBox x:Name="PART_Value" Style="{StaticResource SelectorStyle}" />
...
</ControlTemplate>
<ControlTemplate ...>
...
</ResourceDictionary>

请注意,上面的方法不起作用。特别是,上面的编译,但有一个运行时错误,因为我想要公开可见的 ControlTemplates 找不到上面的私有(private)样式,如“GridStyle”。


尝试了以下方法也没有成功:

    <ResourceDictionary>
<!-- Private dictionary items used to set up the publicly usable Omnibox templates -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>...</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>

<!--CONTROL TEMPLATES -->
<ControlTemplate TargetType="{x:Type local:OmniBox}" x:Key="OBTextBoxTemplate">
...

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