WPF实现纵向显示TabControl标题栏通过设置TabStripPlacement属性,标题字体纵向显示则可通过改变TabItem样式,在其中加入TextBlock控件,使用TextWrapping="Wrap"的特性来实现,具体效果如图:

窗体xaml :
<Window x:Class="VerticalTabDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VerticalTabDemo"
mc:Ignorable="d"
Title="VerticalTabDemo" Height="400" Width="525">
<Window.Resources>
<!--TextBlock样式-->
<Style x:Key="TextBlockStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="Black"></Setter>
<Setter Property="FontSize" Value="26"></Setter>
<Setter Property="TextWrapping" Value="Wrap"></Setter>
<Setter Property="TextAlignment" Value="Center"></Setter>
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
<Setter Property="VerticalAlignment" Value="Bottom"></Setter>
<Setter Property="Height" Value="100"></Setter>
</Style>
<!--Tab样式-->
<SolidColorBrush x:Key="TabControl.

本文介绍了如何在WPF中实现TabControl的标题纵向显示,通过设置TabStripPlacement属性,以及调整TabItem样式,利用TextBlock控件的TextWrapping属性实现文字换行,达到垂直布局的效果。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



