Hide selected TabIItems in WPF TabControl
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. :)
精彩评论