Search code examples
wpfsilverlightxamlcheckboxalignment

How can I align a CheckBox with its content?


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:

enter image description 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.


Solution

  • Edit - New Answer: (previous was no good)

    Not the best way i believe , but can do the work:

    <CheckBox>
        <TextBlock Text="Poorly aligned CheckBox" Margin="0,-2,0,0"/>
    </CheckBox>
    

    Using negative margin to push the content up, result: enter image description here