0
<RibbonWindow x:Class="xxx.yyy"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
...
    <Ribbon x:Name="mainRibbon" Grid.Row="0" >
...
        <RibbonTab Name="ComparisonTab" HorizontalContentAlignment="Left" Header="Comparison" >
            <!--<StackPanel Orientation="Vertical" HorizontalAlignment="Left">-->
            <RibbonGroup HorizontalContentAlignment="Left" Header="Images" >
                <RibbonCheckBox HorizontalAlignment="Left" Width="200" IsChecked="{Binding CompInfo1Check}" Label="{Binding CompInfo1Text}" />
                <RibbonCheckBox HorizontalAlignment="Left" Width="200" IsChecked="{Binding CompInfo2Check}" Label="{Binding CompInfo2Text}" />
                <RibbonCheckBox HorizontalAlignment="Left" Width="200" IsChecked="{Binding CompInfo3Check}" Label="{Binding CompInfo3Text}" />
            </RibbonGroup>
            <!--</StackPanel>-->
        </RibbonTab>

I have some checkboxes with a dynamic text (labels) and I want to have them left aligned within a ribbon group.
I've tried every imaginable combination of Horizontal(Content)Alignment on them and on their parents. I tried to put them into a container (StackPanel, Grid). I even tried to set a label as a separate element.

The checkboxes stubbornly remain centered within a ribbon group. How do I align them horizontally to the left?

user681768917
  • 193
  • 1
  • 12

1 Answers1

0

I've found a workaround in using standard check boxes inside a ribbon. There is no problem with their alignment. They could be styled to look as the ribbon check boxes, if required.

So, the modified xaml is:

        <RibbonTab Name="ComparisonTab" HorizontalContentAlignment="Left" Header="Comparison" >
            <RibbonGroup Header="Images" >
                <StackPanel Orientation="Vertical" HorizontalAlignment="Left">
                    <CheckBox Height="25" IsChecked="{Binding CompInfo1Check}" Content="{Binding CompInfo1Text}" />
                    <CheckBox Height="25" IsChecked="{Binding CompInfo2Check}" Content="{Binding CompInfo2Text}" />
                    <CheckBox Height="25" IsChecked="{Binding CompInfo3Check}" Content="{Binding CompInfo3Text}" />
                </StackPanel>
            </RibbonGroup>
        </RibbonTab>

EDIT
Probably a better way is to use a grid, RibbonCheckBox without a label and a TextBlock instead. Explained here.

Community
  • 1
  • 1
user681768917
  • 193
  • 1
  • 12