First of all, do not waste time on VerticalAlignment or VerticalContentAlignment (or even ControlTemplate ). They are not going to do what you want or can expect.
As described in MSDN, a BulletDecorator (which is the control that CheckBox and RadioButton uses to render the radio / check buttons) will automatically set the icon position. You have no additional control over this:
A Bullet always aligns with the first line of text when a Child object is a text object. If the Child object is not a text object, the Bullet is centered on the Child object.
If you do not change the control template (optional), you can place the radio / check icon at the top if the content is text.
So, if you do something like this, it wonβt look good, because you wonβt be able to move the icon no matter how many VerticalAlignment properties you are trying to set.
<RadioButton> <StackPanel> <TextBlock Text="First line"/> <TextBlock Text="Something else"/> </StackPanel> </RadioButton>
BUT , fortunately, you can put anything you want into a TextBlock using InlineUIContainer . The text (or content) in the first line will automatically determine the position of the icon. If you want something under the first line that is not text, just use <Linebreak/> and then <InlineUIContainer/>
Here is an example that an oversized TextBox to show more clearly what is happening.
<RadioButton> <TextBlock VerticalAlignment="Top" TextWrapping="Wrap"> <TextBlock Text="Products with <" VerticalAlignment="Center" Margin="0,0,5,0"/> <InlineUIContainer BaselineAlignment="Center"> <TextBox FontSize="30" Width="25" Text="10" Margin="0,0,5,0"/> </InlineUIContainer> <TextBlock VerticalAlignment="Center" Margin="0,0,5,0"> <Run Text="days" FontWeight="Bold"/> <Run Text="inventory" /> </TextBlock> <LineBreak/> <InlineUIContainer> <StackPanel> <CheckBox Content="Include unsold products" /> <CheckBox Content="Include something else" /> </StackPanel> </InlineUIContainer> </TextBlock> </RadioButton>
Simon_Weaver
source share