【发布时间】:2014-04-01 09:49:47
【问题描述】:
我是 WPF 新手,
我无法将组框标题文本“abc”向右对齐,它停留在左侧,不知道为什么,谁能帮助我吗?
<Window x:Class="UserInterface.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="500" Width="625">
<Grid ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="4*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="1">
<GroupBox>
<GroupBox.Header>
<DockPanel>
<TextBlock HorizontalAlignment="Right">abc</TextBlock>
</DockPanel>
</GroupBox.Header>
</GroupBox>
</StackPanel>
</Grid>
</Grid>
</Window>
【问题讨论】:
-
您必须编辑
GroupBox的ControlTemplate,因为标题被硬编码为使用Grid和列排列在其中左对齐。