0

別の ResourceDictionary で _brush_backcolor001 を参照するにはどうすればよいですか? このように機能していません:

<ResourceDictionary 

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:s="clr-namespace:System;assembly=mscorlib">

    <ResourceDictionary x:Key="_rd001">
        <SolidColorBrush x:Key="_brush_backcolor001">#FF8FBC8F</SolidColorBrush>
    </ResourceDictionary>

    <Style TargetType="Paragraph" x:Key="_stylePara001">
        <Setter Property="TextElement.Background">
            <Setter.Value>
                <DynamicResource ResourceKey="_brush_backcolor001" />
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
4

1 に答える 1

0

他のリソース ディクショナリのリソースを使用する場合は、次のように指定してマージできます。ResourceDictionary.MergedDictionaries

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary>
            <SolidColorBrush x:Key="_brush_backcolor001">#FF8FBC8F</SolidColorBrush>
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>
    <Style TargetType="Paragraph" x:Key="_stylePara001">
        <Setter Property="TextElement.Background">
            <Setter.Value>
                <DynamicResource ResourceKey="_brush_backcolor001" />
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

_brush_backcolor001別のファイルに抽出し、プロパティRecourceDictionaryを介して参照できる場所Source

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="path/to/separate/resouce/file.xaml"/>
</ResourceDictionary.MergedDictionaries>
于 2014-06-18T11:42:12.793 に答える