2011-02-25 4 views
0

ContentControl을 상속하는 DataGridInsertRowPresenter이라는 새 사용자 지정 컨트롤을 만들었습니다. 모든 것이 잘 작동했습니다.사용자 지정 ContentControl에서 템플릿을 만든 후 콘텐츠가 표시되지 않습니까?

그런 다음 템플릿을 변경하고 더 이상 콘텐츠를 표시하지 않는 새로운 스타일을 추가했습니다.

다음
public class DataGridInsertRowPresenter : ContentControl { 
    static DataGridInsertRowPresenter() { 
     DefaultStyleKeyProperty.OverrideMetadata(typeof(DataGridInsertRowPresenter), new FrameworkPropertyMetadata(typeof(DataGridInsertRowPresenter))); 
    } 
} 

내 템플릿은 다음과 같습니다 :

<Style TargetType="{x:Type Primitives:DataGridInsertRowPresenter}" BasedOn="{StaticResource {x:Type ContentControl}}" > 
    <Setter Property="Template" > 
     <Setter.Value> 
      <ControlTemplate> 
       <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

내 코드에 어떤 문제가 여기에 컨트롤은 무엇입니까?

+0

당신이 너무나요 : 당신은 Content라는 속성이 없습니다 Control 이후 ControlTemplateTargetType를 추가해야 이것을위한 lution? 이 경우 제안 된 답변 중 하나라도 답변으로 표시 할 수 있습니까? – bigfoot

답변

0

assemblyinfo.cs에 리소스를 찾을 위치를 알려주는 특성이 누락되었을 수 있습니다. 당신이 당신의 AssemblyInfo.cs에 다음 코드가 있는지 확인 :

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 
//(used if a resource is not found in the page, 
// or application resource dictionaries) 
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 
//(used if a resource is not found in the page, 
// app, or any theme specific resource dictionaries) 

)]

을 그리고 당신의 스타일 generic.xaml을 \ 테마에 있는지 확인 (또는

0

) 병합 사전으로 참조

<ControlTemplate TargetType="{x:Type Primitives:DataGridInsertRowPresenter}"> 
관련 문제