tags:

views:

61

answers:

1

The following xaml looks fine in XP, but the bottom of the text gets cut off in Vista and Windows 7.

<Grid>
    <Border Height="86"
            Margin="10,54,10,0"
            VerticalAlignment="Top"
            BorderBrush="Black"
            BorderThickness="1"/>
    <Label Height="22" 
           Width="100"
           Margin="15,43,0,0" 
           VerticalAlignment="Top" 
           HorizontalAlignment="Left"
           Background="White">Text Over Border</Label>
</Grid>

I realize that I could just increase the Height of the label, but I'm guessing I'll have problems with systems that have different resolution settings, or large text settings. Is there a better way to lay this out?

A: 

As requested by juharr, I'll add my comment as an answer, with a short elaboration:

Why not just auto-size the label vertically?

In WPF, there's rarely a need for pixel values, especially since they're just device-independent pixels anyway. For anything text (including buttons), auto-sizing is almost always the right thing to do, especially considering future localization (which many people forget). Auto-size always vertically, and horizontally if the label is not intended to be word-wrapped. Use a minimum width for best visual results (for buttons a maximum width may be a good thing as well)

OregonGhost