开发者

Hide selected TabIItems in WPF TabControl

开发者 https://www.devze.com 2023-04-07 03:42 出处:网络
I\'m using the TabControl in WPF as a开发者_运维问答 sort of equivalent to the ASP.Net multiview control. I need to make two of the four tabitem headers hidden. What would be the best method of doing

I'm using the TabControl in WPF as a开发者_运维问答 sort of equivalent to the ASP.Net multiview control. I need to make two of the four tabitem headers hidden. What would be the best method of doing this in XAML?


I fixed this by adding DataTriggers to my Template. If my tab is DeTached (Hidden) I set the Visibility property to Collapsed. If it's visiable again I simply set the Visibility property to Visible again.

<DataTrigger Binding="{Binding IsDetached}" Value="True">
    <Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>

<DataTrigger Binding="{Binding IsDetached}" Value="False">
    <Setter Property="Visibility" Value="Visible" />
</DataTrigger>

Edit: Updated based on @Miklós Balogh feedback. Thanks, improved my code as well, haha. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消