Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 350
DeveloperDan Avatar asked Aug 29 '11 15:08

DeveloperDan


People also ask

How do I make checkboxes align?

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.

How do I align a checkbox horizontally?

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.

How do I move a checkbox to the left in HTML?

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.


1 Answers

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.

like image 50
Majid Avatar answered Oct 09 '22 09:10

Majid