2010-03-16 4 views
3

나는 내 자신의 기본 TabItem 클래스를 갖고 그 클래스에서 파생 된 다른 클래스를 사용하려고합니다.WPF에서 TabControl에 사용자 정의 컨트롤 파생 TabItem을 추가하는 방법은 무엇입니까?

public class MyCustomTab : TabItem 
{ 
    static MyCustomTab() 
    { 
     DefaultStyleKeyProperty.OverrideMetadata(typeof(MyCustomTab), new FrameworkPropertyMetadata(typeof(TabItem))); 
    } 
} 

그리고 이것은 내가 상속 클래스를 위해 할 것입니다 :

나는이 같은 MyNs 네임 스페이스에 기본 클래스를 정의

코드 숨김

MyNs 네임 스페이스에 :

public partial class ActualTab : MyCustomTab 
{ 
    public ActualTab() 
    { 
     InitializeComponent(); 
    } 
} 

xaml :

<MyCustomTab x:Class="MyNs.ActualTab" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
<Grid> 

</Grid> 
</MyCustomTab> 

내가 오류는 '태그'MyCustomTab는 'XML 네임 스페이스'http://schemas.microsoft.com/winfx/2006/xaml/presentation '존재하지 않는 "입니다. XAML에서 TabItem 태그를 사용하면 오류가 발생하여 다른 기본 클래스를 정의 할 수 없다고 표시됩니다.

해결 방법?

답변

0

좋아, 나는 그것이 바보 봤는데해야 해요

<MyNs:MyCustomTab x:Class="MyNs.ActualTab" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:MyNs="clr-namespace:MyNs"> 
<Grid> 

</Grid> 
</MyNs:MyCustomTab> 
관련 문제