2012-06-03 5 views
0

기본적으로 탭 항목이 포함 된 사용자 정의 컨트롤을 만들려고합니다. 다음과 같이 다른 라이브러리의 탭 컨트롤에 추가하십시오.다른 어셈블리의 호스트 TabItem

//Grid.xaml in a.dll 

<UserControl x:Name="Grid" x:Class="SomeClass" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"> 

    <TabItem Header="Grid"> 
     <DataGrid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> 
    </TabItem> 

</UserControl> 

//TabView.xaml in b.dll 
<UserControl 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:Views="clr-namespace:SomeClass;assembly=SomeAssembly" x:Class="SomeClass" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"> 

    <TabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" > 

     <Views:GridView/> 

     <TabItem Header="This" /> 
     <TabItem Header="That" /> 


    </TabControl> 
</UserControl> 

제 문제는 실제로 탭을 생성하지만 탭의 머리글을 표시하지 않는다는 것입니다. 내가 제대로하고 있는지, 머리글을 어떻게 보여줄 수 있을지 궁금합니다.

답변

0

문제는 a.dll의 컨트롤이 TabItem이 아니라는 것입니다. UserControl입니다. WPF의 경우 TabItem에서 상속하거나 컴포지션을 사용할 수 있습니다.

//Grid.xaml in a.dll 
<UserControl x:Name="Grid" x:Class="SomeClass" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"> 

    <DataGrid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> 

</UserControl> 


//TabView.xaml in b.dll 
<UserControl 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:Views="clr-namespace:SomeClass;assembly=SomeAssembly" x:Class="SomeClass" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"> 

    <TabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" > 

     <TabItem Header="Grid"> 
      <Views:GridView/> 
     </TabItem> 

     <TabItem Header="This" /> 
     <TabItem Header="That" /> 


    </TabControl> 
</UserControl>