Philip
Philip
CC#
Created by Philip on 10/4/2023 in #help
✅ Working on a WPF Project, how can I get what StackPanel is selected?
Working on a WPF Project, how can I get what StackPanel is selected by the user and save it to use it in my class?
<Style TargetType="ListViewItem">
<Setter Property="Cursor" Value="Hand"/>

<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<StackPanel Orientation="Horizontal" Margin="4" MinHeight="25" Background="{TemplateBinding Background}">
<Image Width="34" RenderOptions.BitmapScalingMode="Fant" Source="{Binding Image}"/>
<TextBlock Text="{Binding Country}" Margin="4,0,0,0" VerticalAlignment="Center"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#1E1E1E"/>
</Trigger>

<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#1E1E1E"/>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="ListViewItem">
<Setter Property="Cursor" Value="Hand"/>

<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<StackPanel Orientation="Horizontal" Margin="4" MinHeight="25" Background="{TemplateBinding Background}">
<Image Width="34" RenderOptions.BitmapScalingMode="Fant" Source="{Binding Image}"/>
<TextBlock Text="{Binding Country}" Margin="4,0,0,0" VerticalAlignment="Center"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#1E1E1E"/>
</Trigger>

<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#1E1E1E"/>
</Trigger>
</Style.Triggers>
</Style>
136 replies