■ FrameworkElement 클래스의 FindResource 메소드를 사용해 리소스를 찾는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
using System.Windows; Style style = null; try { style = this.button.FindResource("RedForegroundStyleKey") as Style; } catch { } if(style != null) { this.button.Style = style; } |
※ 찾고자 하는 리소스가 존재하지 않는 경우 FindResource 메소드는 예외를 발생시킨다.