I'm not able to center text vertically on a default button (no styles or templates used)
I saw threads like
Text content in a WPF button not being centred vertically
^^ I'm not setting any text height atleast in button 1.
Not sure what causes this behavior and how to get rid of it efficiently when localisation comes in.
I do get I can set a -ve margin to align text exactly, however that might screw things up for another language. Is this some limitation based on the Default Font Family Expression blend seems to impose?
Any help with this would be great. Seems trivial but cant seem to find a decent explanation for what's causing this behavior.
Xaml code is as follows:
<Window x:Class="TestButton.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="ButtonFFAH" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" VerticalContentAlignment="Center"/>
<Button Content="ButtonAH" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75"
Margin="80,0,0,0" Height="15.627" VerticalContentAlignment="Center"/>
</Grid>
The apparent vertical misalignment is due to the fact that all kinds of accents or other diacritical marks add to the total font height. Although the actual Button content may not contain such characters, the vertical alignment has to take this into account to ensure a common baseline alignment with other Buttons with the same "outer" alignment, for example in the same Grid row.