0

基本的にタブアイテムを含むユーザーコントロールを作成しようとしています。次のようにして、別のライブラリのタブコントロールに追加してみてください。

//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>

私の問題は、実際にはそこにタブが作成されますが、タブのヘッダーが表示されないことです。私はそれを正しく行っているのだろうか、そしてどうすればヘッダーを表示できますか?

4

1 に答える 1

0

問題は、a.dllのコントロールがTabItemではないことです。UserControlです。TabItemから継承するか(WPFにとっては悪い方法です)、compositionを使用することができます。

//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>
于 2012-06-03T11:16:36.513 に答える