1

假设我有以下 XAML。

我怎样才能实现最外层Button具有这样的高度,以便文本TextBlock完全可见?

<StackPanel>
        <Button HorizontalContentAlignment="Stretch" Width="100" >
            <DockPanel >
                <CheckBox DockPanel.Dock="Left"/>
                <Button DockPanel.Dock="Right" Content="X" />                
                <TextBlock >
  some very long text some very long textsome very long textsome very long textsome very long text
                </TextBlock>
            </DockPanel>
        </Button>
    </StackPanel>
4

2 回答 2

3

设置为TextBlock.TextWrappingWrap当文本到达允许空间的边缘时,它将换行到新行

<TextBlock TextWrapping="Wrap" 
           Text="some very long text some very long textsome very long textsome very long textsome very long text" />
于 2013-03-20T15:31:05.240 回答
0

添加另一个堆栈面板

<StackPanel>
        <Button HorizontalContentAlignment="Stretch" Width="auto" >
            <DockPanel>
                <CheckBox DockPanel.Dock="Left"/>
                <StackPanel>
                    <Button DockPanel.Dock="Right" Content="x" HorizontalAlignment="Right" />
                    <TextBlock Text="some very long text some very long textsome very long textsome very long textsome very long text" />
                </StackPanel>
            </DockPanel>
        </Button>
    </StackPanel>
于 2013-03-20T15:29:01.843 回答