유효 값은 속성 시스템에서 값을 요청하는 호출자에게 반환하는 속성의 값입니다.속성 시스템에서 속성 시스템 값 우선 순위에 참가하는 가능한 모든 입력을 계산하면 유효 값이 생성됩니다.여기에는 강제 형 변환 및 애니메이션이 포함됩니다.자세한 내용은 종속성 속성 값 우선 순위을 참조하십시오.
이 메서드는 UnsetValue를 반환하지 않습니다.UnsetValue는 내부적으로 다양한 기능에 사용되며 강제 형 변환 콜백을 통해 노출되기도 하는 속성 시스템에 대한 센티널 값입니다.
속성의 형식이 확실하지 않는 경우에는 요청된 종속성 속성의 식별자를 쿼리하여 반환 값을 변환할 수 있는 보다 구체적인 PropertyType이 있는지를 확인할 수 있습니다.
public class MyStateControl : ButtonBase
{
public MyStateControl() : base() { }
public Boolean State
{
get { return (Boolean)this.GetValue(StateProperty); }
set { this.SetValue(StateProperty, value); }
}
public static readonly DependencyProperty StateProperty = DependencyProperty.Register(
"State", typeof(Boolean), typeof(MyStateControl),new PropertyMetadata(false));
}
또다른 예제
아래 메소드는 자기위치부터 아래로 컨트롤 찾는 메소드 입니다.
여기서는 string controlName = child.GetValue(Control.NameProperty) as string;
이렇게 컨트롤의 이름을 가지고 오고 있습니다
/// <summary>
/// 자신의 컨트롤 한단계 아래부터 사용자정의 이름으로 검색합니다.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="_Control"></param>
/// <param name="_FindControlName"></param>
/// <returns></returns>
private T FindVisualChildByName<T>(Control _Control, string _FindControlName) where T : FrameworkElement
{
T t = null;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(_Control); i++)
{
var child = VisualTreeHelper.GetChild(_Control, i);
string controlName = child.GetValue(Control.NameProperty) as string;
if (controlName == _FindControlName)
{
t = child as T;
}
}
return t;
}'WPF' 카테고리의 다른 글
| [DataGridCell / Setter ] 특정 Cell 만 변경하기 (0) | 2010.11.26 |
|---|---|
| [WPF Blend4/MouseDrag/MouseDragElementBehavior ] 창 가운데 띄우기 / 마우스드래그 (0) | 2010.11.24 |
| WPF Dialog Box/ ValidationRule 파일열기 유효성검사 (0) | 2010.10.20 |
| [ADO.NET Entity Data Model ]실버라이트 초간단 데이터 바인딩 (0) | 2010.10.14 |
| [VisualTreeHelper] 부모컨트롤 찾기 / 자식컨트롤 찾기 (0) | 2010.09.16 |
| [Blend4 / DataGrid / DataTemplate / CellEditingTemplate / Edit] 데이터그리드 편집모드 사용하기 (0) | 2010.09.16 |
| StaticResource 와 DynamicResource 의 차이 (0) | 2010.09.15 |
| [StringFormat] 초간단 날짜 표시방법변경 (0) | 2010.09.01 |
| [NavigationService / PageFunction] 페이지 이동 (2) | 2010.08.23 |
| [Canvas] 캔버스안의 컨트롤을 캔버스 가운데 띄우기 (0) | 2010.08.03 |