开发者

wpf: Label in toolbar gets clipped

开发者 https://www.devze.com 2023-01-22 20:38 出处:网络
If I create a toolbar with a label and a button like this: <ToolBar Height=\"26\" > <Label>Hi mom</Label>

If I create a toolbar with a label and a button like this:

    <ToolBar Height="26" >
        <Label>Hi mom</Label>
        <Button>Press me</Button>
    </ToolBar>

The button text centers on the toolbar and does not get clipped.

wpf: Label in toolbar gets clipped

How can I make the text on the label appear with an equal apperanc开发者_StackOverflow中文版e as the button?


Update

Here's how to do it with a Label (fixed Left/Right padding)

<ToolBar Height="26" >
    <Label Padding="5,0,5,0" VerticalAlignment="Center">Hi mom</Label>
    <Button>Press me</Button>
</ToolBar>


Ok, I figured out the TextBlock version:

This creates a textblock which creates a similar apperance as the button:

        <TextBlock Margin="2 2 3 0"  VerticalAlignment="Center" Text="Press Me"></TextBlock>
0

精彩评论

暂无评论...
验证码 换一张
取 消