Here is the code for my ItemsControl, which scales objects on mouse click.
I am unable to increase the ZIndex of the current enlarged item to shift it to the rest.
<ItemsControl ItemsSource="{Binding Path=Value}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Name}" RenderTransformOrigin="0.5 0.5"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="RenderTransform"> <Setter.Value> <ScaleTransform ScaleX="1.5" ScaleY="1.5" /> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> </DataTemplate> </ItemsControl.ItemTemplate> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Horizontal" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel>
I tried to change ZIndex directly in the trigger, but it does not work.
It seems I need to change ZIndex in ContentPresenter, which is the parent of TextBlock in VisualTree, and not directly in TextBlock.
<Setter Property="Panel.ZIndex" Value="99" />
So, I tried changing ZIndex in ContentPresenter, but it still does not work.
<ItemsControl.ItemContainerStyle> <Style TargetType="{x:Type ContentPresenter}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Panel.ZIndex" Value="99" /> </Trigger> </Style.Triggers> </Style> </ItemsControl.ItemContainerStyle>
Does anyone know how this works?
source share