- WPF(XAML, XBAP, .NET4.0)GUIプログラミング Part21 [無断転載禁止]©2ch.net
850 :デフォルトの名無しさん[]:2017/12/07(木) 10:16:38.26 ID:vSHyWsbi - ListBoxの行のマウスオーバーおよび選択時において、
背景の色を赤に変更したいのですが、どのようにしたら良いでしょうか? 下記のコードだと、フォントのサイズは変更されるのですが、 背景はデフォルトのままです。 以上よろしくお願いいたします。 <Grid Margin="5"> <ListBox> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="Red" /> <Setter Property="FontSize" Value="15" /> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="Red" /> <Setter Property="FontSize" Value="15" /> </Trigger> </Style.Triggers> </Style> </ListBox.ItemContainerStyle> <ListBoxItem Content="item1" /> <ListBoxItem Content="item2" /> <ListBoxItem Content="item3" /> </ListBox> </Grid>
| - WPF(XAML, XBAP, .NET4.0)GUIプログラミング Part21 [無断転載禁止]©2ch.net
852 :デフォルトの名無しさん[]:2017/12/07(木) 13:40:41.72 ID:vSHyWsbi - >>851
回答ありがとうございます。 おっしゃる通りコントロールテンプレートでした。 ttps://blog.jsinh.in/change-background-color-of-selected-listboxitem-listbox-in-wpf/#.WijFpEpl-Ul 上記のページを参照したらクリックの挙動もうまくできました。
|
|