Я использую шаблон для своего флажка:
<Style x:Key="StyleCheckboxError" TargetType="{x:Type CheckBox}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background" Value="{StaticResource CheckBoxFillNormal}"/>
<Setter Property="BorderBrush" Value="{StaticResource CheckBoxStroke}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{StaticResource EmptyCheckBoxFocusVisual}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Grid x:Name="IGridMain">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Checked">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="IRectError">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Unchecked"/>
<VisualState x:Name="Indeterminate"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="IRectError" Fill="{DynamicResource BrushTBPRed}" Margin="2" Stroke="Black" Visibility="Hidden"/>
<Border BorderBrush="{DynamicResource BrushTBPShadow}" BorderThickness="0,0,2,2" Margin="0" Padding="0" Height="Auto" VerticalAlignment="Stretch"/>
<Border BorderBrush="{DynamicResource BrushTBPBlack}" BorderThickness="2,2,0,0" Margin="0" Padding="0" Height="Auto" VerticalAlignment="Stretch"/>
<ContentPresenter Margin="2,2,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasContent" Value="true">
<Setter Property="FocusVisualStyle" Value="{StaticResource CheckRadioFocusVisual}"/>
<Setter Property="Padding" Value="4,0,0,0"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Как вы видите, ContentPresenter выровнен по центру.Все хорошо для короткого контента, но когда контент многострочный, выровненный по левому краю текст находится в центре флажка. Как я могу изменить выравнивание текста в ContentPresenter
Спасибо ..