I know the question sounds a little strange, but I'd like to change the opacity of all the items not selected in an ItemsControl. In other words, I'd like to make more "visible" the selected item, showing the others item more "obfuscated".
I have a custom control "MyCustomControl" derived from ItemsControl, where each item is an instance of a class "MyObject".
I made a style for my custom control where I set the ItemTemplate to be an Image with Source property bound to the property "LargeImage" of "MyObject". Here comes the problem. When I select an item I'd like to set the opacity of the others element, but I haven't found a way!
Here's my (simplified) XAML code:
<Style TargetType="{x:Type MyCustomControl}" x:Key="MyStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ui:MyCustomControl}">
<Border Height="{TemplateBinding Height}" Width="Auto" Background="{TemplateBinding Background}">
<ItemsPresenter VerticalAlignment="Center" IsHitTestVisible="True"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<Button>
<Image Source="{Binding Path=LargeImage}" Stretch="Uniform"/>
</Button>
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>