Hello,
I'm using an Infragistics XamCarouselListBox in an C# WPF MVVM Application.
I'm trying to create a trigger that changes the background of the selected item, in the moment it gets clicked.
My problem is that I don't really know where to create the trigger (Grid, CarouselListBox Style...) and how to properly catch that the item got clicked.
Afterwards, when it's not selected anymore, it should have its normal color.
The XamCarouselListBox uses a DataTemplate with a Grid and a TextBlock in it.
Thanks.
Achim
Hello Achim,
Setting the CarouselItemSelected brush to a custom color will change the appearance of the selected item in the XamCarouselListBox:
<igWindows:XamCarouselListBox.Resources>
<SolidColorBrush
x:Key="{ComponentResourceKey {x:Type igWindows:IGControlBase}, CarouselItemSelected}"
Color="Yellow" />
</igWindows:XamCarouselListBox.Resources>
Please do not hesitate to let me know if you have any other questions.
Hello Maria,
that isn't exactly what I need.
I want to accomplish one thing:
<igWindows:XamCarouselListBox.Resources> <SolidColorBrush x:Key="{ComponentResourceKey {x:Type igWindows:IGControlBase}, CarouselItemSelected}" Color="Transparent" /></igWindows:XamCarouselListBox.Resources>
With this behavior (if it works one day), the carousel only displays the current selected item with the color of its background.
Hi Achim,
Thank you for the provided details. The background color for the selected items depends on the CarouselItemSelected color as you have mentioned. In a scenario where an ItemTemplate with a Border is set for the XamCarouselListBox the background color can be modified by setting a style with a trigger for the border:
<Style TargetType="{x:Type Border}" x:Key="borderStyle">
<Setter Property="Background" Value="Pink"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igWindows:CarouselListBoxItem}}, Path=IsSelected}" Value="true">
<Setter Property="Background" Value="Plum"/>
</DataTrigger>
</Style.Triggers>
</Style>
A sample project which is illustrating this approach is attached.
Please do not hesitate to ask if you have any other questions.