如何在下面的状态栏中找到TextBlock以对齐?
我告诉过它:
但是文字仍然不合情理地坐在左边.我还有什么要说的?
<Window x:Class="TestEvents124.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300"
MaxWidth="700" Width="700"
>
<DockPanel HorizontalAlignment="Stretch" Margin="0,0,0,0" Width="Auto">
<StatusBar Width="Auto" Height="25" Background="#888" DockPanel.Dock="Bottom" HorizontalAlignment="Stretch">
<TextBlock
Width="Auto"
Height="Auto"
Foreground="#fff"
Text="This is the footer."
HorizontalAlignment="Right"
TextAlignment="Right"
/>
</StatusBar>
<GroupBox DockPanel.Dock="Top" Height="Auto" Header="Main Content">
<WrapPanel Width="Auto" Height="Auto">
<TextBlock Width="Auto" Height="Auto" TextWrapping="Wrap" Padding="10">
This is an example of the content, it will be swapped out here.
</TextBlock>
</WrapPanel>
</GroupBox>
</DockPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)
Mat*_*ton 16
我已经玩了你的代码,并通过使用StatusBarItem而不是TextBlock设法让它看起来"正确"(没有双关语):
<StatusBar Width="Auto" Height="25"
Background="#888" DockPanel.Dock="Bottom"
HorizontalAlignment="Stretch" >
<StatusBarItem Foreground="#fff"
HorizontalContentAlignment="Right">This is the footer</StatusBarItem>
</StatusBar>
Run Code Online (Sandbox Code Playgroud)
不确定TextBlock发生了什么 - 我的所有经验都表明HorizontalContentAlignment和HorizontalAlignment(在StatusBar和TextBlock上)的某些组合应该达到你想要的效果.无论如何 - 希望StatusBarItem适合你.