Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
Multiple DataTemplates for ComboEditorItems
posted

I am trying to set DataTemplates for the items in a XamComboEditor.  With the standard ComboBox I just specified a DataTemplate in the Resources with a DataType parameter:

        <DataTemplate DataType="{x:Type local:ContactComboTextItem}">
            <TextBlock Text="{Binding Text}" Margin="{Binding Margin}">
            </TextBlock>
        </DataTemplate>
 
        <DataTemplate DataType="{x:Type local:ContactComboHyperLinkItem}">
            <TextBlock Margin="{Binding Margin}" Width="{Binding Width}">
                <Hyperlink Click="Hyperlink_Click">
                    <TextBlock Text="{Binding Path=Text}"/>
                </Hyperlink>
            </TextBlock>
        </DataTemplate>
 
        <DataTemplate  DataType="{x:Type local:ContactComboGroupHeaderItem}">
            <Grid  Width="{Binding Width}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="20" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="2" />
                </Grid.RowDefinitions>
                
                <Image Grid.Row="0" Grid.Column="0" Source="{Binding ImageSource}" Width="16" Height="16" Margin="2,2,2,2"/>
                <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Text}" FontWeight="Bold"  Margin="10,2,2,2" />
                <Rectangle Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
                    <Rectangle.Fill>
                        <LinearGradientBrush>
                            <GradientStop Color="#FF5397D1" Offset="0.0" />
                            <GradientStop Color="#FF3EC4E8" Offset="1.0" />
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
            </Grid>
        </DataTemplate>
 
        <DataTemplate x:Key="ContactComboContactItem">
            <ContentPresenter Content="{Binding ContactContent}" Margin="{Binding Margin}" />
        </DataTemplate>

 

This does not work with the XamComboEditor. How should I select different DataTemplates based on the type of object in the Items collection?

Thanks,

Glen

Also,  How do I paste code in here without cutting if off?

Parents Reply Children
No Data