The look of a WPF CheckBox misaligns the check portion with the label (content) portion. The check stays slightly above the content as shown here:
The XAML looks like this:
<CheckBox Content="Poorly aligned CheckBox" Margin="9"/>
The CheckBox is inside a Grid cell. Is there a simple way to make the content and check portions of a XAML CheckBox align vertically? I've tried various combinations of properties with no luck. I saw a similar question here but the answer is way too complex.
Thanks in advance.
EDIT: The problem was caused by the Window FontSize which I set to 14. To re-create the problem set the CheckBox FontSize to 14 (or more). My program is viewed at a distance by factory workers so I allow the Window FontSize to be increased or decreased by the user.
Put each checkbox and label within an <li> element. Add overflow:hidden to the <li> and float the label and checkbox left. Then they all align perfectly fine.
Set the checkbox horizontally by including the data-type = "horizontal" to the fieldset. You can select the checkbox button more than one at a time.
You can't align or change a checkbox's direction, because it has no attachment, it's just a box. Show activity on this post. Set its width to like 20px, that fixes the problem.
I know it's too late, but here is a better solution, without setting margins. Margins should be set differently for different heights of TextBlock
or Checkbox
.
<CheckBox VerticalAlignment="Center" VerticalContentAlignment="Center"> <TextBlock Text="Well aligned Checkbox" VerticalAlignment="Center" /> </CheckBox>
Update:
It's worth checking out @nmarler's comment below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With