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
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] x:TypeArguments 속성 사용하기 (0) | 2014.01.11 |
---|---|
[C#/WPF] InkCanvas 클래스 : XAML 데이터 저장하기 (0) | 2014.01.10 |
[C#/WPF] InkCanvas 클래스 : ISF 데이터 저장하기 (0) | 2014.01.10 |
[C#/WPF] InkCanvas 클래스 : 데이터 로드하기 (0) | 2014.01.10 |
[C#/WPF] Tablet 클래스 : Tablet 장치 설치 여부 조사하기 (0) | 2014.01.10 |
[C#/WPF] x:Key 속성 : x:Static 태그 확장을 사용해 시스템 리소스 재정의 하기 (0) | 2014.01.10 |
[C#/WPF] StaticResource 태그 확장 : x:Static 태그 확장을 사용해 시스템 리소스 사용하기 (0) | 2014.01.10 |
[C#/WPF] DynamicResource 태그 확장 : 정적 속성 값 사용하기 (0) | 2014.01.10 |
[C#/WPF] DynamicResource 엘리먼트 : 정적 속성 값 사용하기 (0) | 2014.01.10 |
[C#/WPF] StaticResource 태그 확장 : 리소스 사용하기 (0) | 2014.01.10 |
댓글을 달아 주세요