Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Commented Unassigned: CheckComboBox - When item text is on multiple line, checkbox is aligned to top [20214]

$
0
0
When the text of an item is on multiple lines, the check box vertical alignment property is aligned to top.
I would expect it to be centered.
Comments: ** Comment from web user: BoucherS **

Hi,

When creating a regular CheckBox with many lines of text, the checkBox vertical alignment property is aligned to top. So we keep this behavior.

If you want to modify it in th CheckComboBox, you can redefine the ItemContainerStyle with the VerticalContentAlignement property set to "Center".

Here's an example :
```
<DataTemplate x:Key="WrappingComboTemplate">
<TextBlock Text="{Binding}" TextWrapping="Wrap"/>
</DataTemplate>

<Style x:Key="MyItemContainerStyle" TargetType="{x:Type xctk:SelectorItem}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="{x:Type xctk:SelectorItem}">
<Border x:Name="_background"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<CheckBox VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
IsChecked="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}}"
Content="{TemplateBinding Content}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="_background" Property="Background" Value="#FFB8E0F3" />
<Setter TargetName="_background" Property="BorderBrush" Value="#FF26A0DA" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>


<xctk:CheckComboBox " x:Name="_checkListBox"
Width="200" Height="25" MaxWidth="200"
ItemContainerStyle="{StaticResource MyItemContainerStyle}"
ItemTemplate="{StaticResource WrappingComboTemplate}"/>
```


Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>