0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【WPF】 TabControl の Header を XAML で 非表示にする方法

Posted at

タブのページ切り替え機能は使いたいけど、デザイン的にタブは使いたくない。例えばナビゲーションメニューの選択でタブを切り替えたい、そう思ったことはありませんか?

WPFのTabContorlでHeaderを非表示にする方法が、くぐっても出てこなかったので、忘備録として記録しておきます。

TabControlのHeader を非表示にするXAML

TabControl のXAMLを下記の様に記述すれば非表示にできます。

<TabControl>
    <TabControl.ItemContainerStyle>
        <Style TargetType="TabItem">
            <Setter Property="Visibility" Value="Collapsed"/>
        </Style>
    </TabControl.ItemContainerStyle>
</TabControl>

タブページを含めるとこんな感じです。

<TabControl >
    <TabControl.ItemContainerStyle>
        <Style TargetType="TabItem">
            <Setter Property="Visibility" Value="Collapsed"/>
        </Style>
    </TabControl.ItemContainerStyle>
    
    <TabItem>
        <TextBox Width="200" Height="30" Text="aaaaa" />
    </TabItem>

    <TabItem>
        <TextBox Width="200" Height="30" Text="bbbbb" />
    </TabItem>

    <TabItem>
        <TextBox Width="200" Height="30" Text="ccccc" />
    </TabItem>
</TabControl>

もしこれでも少し隙間が出る場合、TabItem の PaddingとMarginを 0 にしてみて下さい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?