2

次のように定義されたコントロールを含む CustomControl ライブラリがあります。

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfCustomControlLibrary1">

<SolidColorBrush x:Key="Test"
                 Color="Red" />

<Style TargetType="{x:Type local:CustomControl1}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:CustomControl1}">
                <Border Background="{StaticResource Test}" />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

これはうまくいきます。

しかし、「StaticResource」を「DynamicResource」に変更すると、赤が拾われなくなりますか?

どうしてこれなの?

4

1 に答える 1