파일내에서 참조

<Window.Resources>

<!--Window내에서 모두 사용가능-->

<SolidColorBrush x:Key="yellowBrush" Color="Yellow"/>

</Window.Resources>

<StackPanel>

<!--확장프로퍼티{}-->

<!--실제코드는 전과 차이가 없지만. 일괄수정시 편하다-->

<Button Margin="5,5" Background="{StaticResource yellowBrush}">버튼</Button><Button Margin="5,5" Background="{StaticResource yellowBrush}">버튼</Button>

</StackPanel>

 

프로젝트(?) 전체에서 참조 - ResourceDitionary 사용

 

-ResourceDictionary

 

<--프로젝트 솔루션에서 /추가 - 리소스사전/  (Dictionary1.xaml) -->

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<SolidColorBrush x:Key="testBrush" Color="Red"/><!--단일자원 리소스-->

</ResourceDictionary>

-사용

 

 

<Window.Resources>

<ResourceDictionary Source="Dictionary1.xaml"/><!--리소스사전 참조-->

</Window.Resources>

<StackPanel>

<!--사용방법은 똑같다-->

<Button Background="{StaticResource testBrush}">버튼1</Button>

<Button Background="{StaticResource testBrush}">버튼2</Button>

<Button Background="{StaticResource testBrush}">버튼3</Button>

</StackPanel>



by 피요히코~ 2009. 2. 25. 12:55
| 1 |