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
25
XamCarouselListBox ItemTemplate for selected item
posted

Hi. I'm evaluating Infragistis WPF stuff. Looks great so far. However, I'm struggling with a feature.

I'm building on the examples for the xamCarouselListBox in xamFeatureBrowser. I want to replace the datatemplate for the listboxitem when an item is selected. But no matter what I do, the selected listbox item will not change. This is really important to me and hopefully someone can tell me where I go wrong. Here's the part of the code that I suppose is significant:

<Style TargetType="{x:Type igWindows:CarouselPanelItem}" x:Key="ContainerStyle">
                <Setter Property="ContentTemplate" Value="{StaticResource SimpleDataTemplate}" />
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="ContentTemplate" Value="{StaticResource SeletedDataTemplate}" />
                    </Trigger>
                </Style.Triggers>
            </Style>

Thanks in advance.
Best wishes
Kai Bohli
Norway 

Parents
  • 2677
    posted

    Hello Kai,

    If you want to trigger the selection of the CarouselListBoxItems and give them a different template when selected, you will have to do the following. 

    First, you will need to Target the CarouselListBoxItem rather then the CarouselPanelItem.  Then, Set up dataTriggers to resemble the following.

    <Style TargetType="{x:Type igWindows:CarouselListBoxItem}">            
                    <Style.Triggers>
                        <DataTrigger  Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="True">
                            <Setter Property="ContentTemplate" Value="{StaticResource SelectedDataTemplate}" />
                        </DataTrigger>
                        <DataTrigger  Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="False">
                            <Setter Property="ContentTemplate" Value="{StaticResource CLBItemDataTemplate}" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>

    Now, when I select an item in the list, it will change templates.  I have attached a sample to this post.  Please test it at your end to verify it resolves you issue. 

    XCLB_SelectedItemTemplate.zip
Reply Children
No Data