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

New Post: CheckComboBox - ItemTemplate

$
0
0
Hi,

I used your code to make some tests :
First, make sure the Visibility of the CheckComboBox is Visible :-)
Then, only using the ItemTemplate for the CheckComboBox, the Converter does its job.
Then adding the ItemContainerStyle to the CheckComboBox prevent the Converter from doing its job...like you point out.
In the ControlTemplate of the comboItemContanerStyle, there is a ContentPresenter. Simply add
ContentTemplate="{TemplateBinding ContentTemplate}"
to it. It will do the job.

Here's the complete xaml
<Window x:Class="WpfApplication88.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:local="clr-namespace:WpfApplication88"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <Style x:Key="comboItemContanerStyle"
               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}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <CheckBox VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                          IsChecked="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}}"
                                          Grid.Column="0" />
                                <ContentPresenter Content="{TemplateBinding Content}"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Grid.Column="1"
                                                  Margin="5,0,0,0" />
                            </Grid>
                        </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>

        <local:MyConverter x:Key="convert" />

        <DataTemplate x:Key="WrappingComboTemplate">
            <TextBlock Text="{Binding Converter={StaticResource convert}}" />
        </DataTemplate>
    </Window.Resources>
    
    <Grid>
        <xctk:CheckComboBox x:Name="_checkComboBox"
                            VerticalAlignment="Bottom"
                            MaxHeight="50"
                            Visibility="Visible"
                            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                            ItemContainerStyle="{StaticResource comboItemContanerStyle}"
                            ItemTemplate="{StaticResource WrappingComboTemplate}"/>
    </Grid>
</Window>

Viewing all articles
Browse latest Browse all 4964

Trending Articles



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