2
WPF 응용 프로그램에서 작업 중이며 ListViewItem
에 스타일을 만들고 싶습니다. 이 스타일을 만들었지 만 이것이 내가 원하는 결과를 내게주지는 못합니다. 이 외에도이 스타일에서 CornerRadius
을 어떻게 추가 할 수 있을까요?ListView SelectedItem에서 스타일을 만드는 방법.?
<ListView x:Name="MenuBarList"
Grid.Row="1"
Height="{Binding MainMenuHeight}"
Width="{Binding MainMenuWidth}"
ItemsSource="{Binding Path=Menu.Options}"
SelectedItem="{Binding Path=SelectedMainMenuOption, Mode=TwoWay}"
Foreground="White"
Background="Transparent"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsSynchronizedWithCurrentItem="True"
IsTabStop="False">
<ListView.Style>
<Style TargetType="{x:Type ListView}">
<Setter Property="BorderBrush" Value="White"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Width" Value="300"/>
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#9449b0"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#9449b0"/>
</Style.Resources>
</Style>
</ListView.Style>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Focusable="False" VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="{Binding IconPath}"
Focusable="False"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsHitTestVisible="False"/>
<TextBlock Text="{Binding Title}"
Focusable="False"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="Segoe UI"
FontSize="26"
IsHitTestVisible="False"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
원하는 결과가 필요합니다. SeletedItem이 분홍색으로 강조 표시되고 cornerRadius가 필요합니다. –
XAML에 코드를 넣었으므로 selectedItem의 둥근 모서리를 볼 수 있습니다. –
슬프게도, GridView에서 작동하지 않습니다. –