첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ ResourceDictionary 엘리먼트를 사용해 리소스를 병합하는 방법을 보여준다. 동일한 키가 존재하는 경우, 메인 리소스 사전에 해당 리소스가 있으면 우선적으로 참조된다. 메인 리소스 사전에 해당 리소스가 없는 경우 병합된 리소스 사전에서 해당 키가 존재하는 병합 리소스 사전 중에서 마지막 리소스 사전에 포함된 리소스가 참조된다.

 

▶ MainApplication.xaml

...
<Application.Resources>
    <ResourceDictionary>
        <Style x:Key="ButtonForegroundStyleKey">
            <Setter Property="Button.Foreground" Value="Yellow" />
        </Style>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="MyResources1.xaml" />
            <ResourceDictionary Source="MyResources2.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
...

 

▶ MyResource1.xaml

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="ButtonForegroundStyleKey">
        <Setter Property="Button.Foreground" Value="Red" />
    </Style>
</ResourceDictionary>

 

▶ MyResource2.xaml

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="ButtonForegroundStyleKey">
        <Setter Property="Button.Foreground" Value="Blue" />
    </Style>
</ResourceDictionary>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요