Vertically aligning Labels and TextBlocks at Top in XAML

后端 未结 3 1978
小蘑菇
小蘑菇 2021-02-14 13:35

How can I vertically align a Label and TextBlock at Top so that their first lines of text line up?


    

        
相关标签:
3条回答
  • 2021-02-14 14:06

    The extra space around the label comes from the Padding property. To remove the space, you can explicitly set the Padding property to "0" directly on the Label, or, of course, set it via a Style.

    0 讨论(0)
  • 2021-02-14 14:12

    Here is a workaround: Align bottoms of text in controls.

    I posted a connection: https://connect.microsoft.com/WPF/feedback/ViewFeedback.aspx?FeedbackID=523432, please vote.

    0 讨论(0)
  • 2021-02-14 14:25
    <TextBlock>
    <InlineUIContainer BaselineAlignment="Top"><Label Content="Label"/></InlineUIContainer>
    <InlineUIContainer BaselineAlignment="Top"><TextBlock>TextBlock Content</TextBlock>                 </InlineUIContainer>
    </TextBlock>
    

    HTH.

    0 讨论(0)
提交回复
热议问题