공부/WPF
ResourceDictionary 추가하기
잠수함토끼
2015. 3. 24. 22:38
1. 추가 버튼을 누른다.
2. 추가한 XAML에 다음과 같이 TEST CODE를 작성한다.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Name ="TEST1" TargetType="{ x:Type Button}">
<Setter Property ="Background" Value="Red"/>
</Style >
</ResourceDictionary> |
3. 다음과 같이 추가한 DICATIONARY를 추가하면 어디서든 사용 가능하다.
<Window x :Class="WpfApplication33.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height ="350" Width="525">
<Window.Resources >
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source ="Dictionary1.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources >
<Grid >
<Button Style ="{StaticResource TEST1 }" Content="BUTTON"/>
</Grid >
</Window> |