2014-02-13 4 views
0

는이 같은 종속성 속성을 정의하기 위해 노력하고WPF 종속성 속성 오류

{"Default value type does not match type of property 'DepName'."} 
+0

이 도움이 될 수 있습니다 : http://stackoverflow.com/questions/20398751/the-default-value-type-does-not-match-the-type-of-the-property –

답변

1

기본값 유형 (String) 의 Dependency Property가 DepName (EnumName) 속성의 Type과 일치하지 않습니다.

종속성 속성의 기본 형식을 변경하면 제대로 작동합니다.

public static readonly DependencyProperty DependencyPropertyName= DependencyProperty.Register(
    "DepName", 
    typeof(EnumName), 
    typeof(MyWindow1), 
    new FrameworkPropertyMetadata(
     EnumName.SomeValue, // this is the defalt value 
     FrameworkPropertyMetadataOptions.AffectsRender, 
     Target)); 
+0

도움을 주셔서 감사합니다 , 내가 어떻게 그리워하는지 모르겠다. ( – Rock3rRullz

+0

때때로 코드에서 눈이 멀어지기 쉽다. 코드에서 조금 벗어나 신선한 눈으로 돌아 가면된다. 점심 식사는 보통 트릭); – Eirik

+0

종속성 속성 식별자 필드의 이름 지정 규칙이 있음을 유의하십시오. 당신은'DependencyPropertyName' 대신'DepNameProperty'라고해야합니다. MSDN에서 [Dependency Property 정의를위한 검사 목록] (http://msdn.microsoft.com/en-us/library/ms753358.aspx#checklist)의 * Dependency Property Name Conventions * 섹션을 참조하십시오. – Clemens