2番目の質問はうまくいけば簡単ですが、私はリストボックスコントロールで選択した項目の前景色を変更するだけです。リストボックスの選択テキストの色
私は(選択の背景ではなく、フォアグラウンドの色を変更する)次のスタイルを持っている:
:これも<Style TargetType="ListBoxItem" x:Key="PinnedListBoxItem">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF9CC164"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#FF9CC164"/>
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
動作しない
<Style TargetType="ListBoxItem" x:Key="PinnedListBoxItem">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF9CC164"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#FF9CC164"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White"/>
</Style.Resources>
</Style>
私は、次のリストボックスを持っています
<ListBox Style="{StaticResource PinnedList}" Height="Auto" MaxHeight="200" Visibility="Hidden" HorizontalAlignment="Left" Margin="-8,45,0,0" SelectionChanged="ui_lsbPinnedORGs_SelectionChanged"
SelectedItem="{Binding Path=SelectedPinnedORGsViewModel, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, Mode=TwoWay}"
SelectionMode="Single" ItemsSource="{Binding Path=ORGViewModels, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, Mode=TwoWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" MouseEnter="ui_lsbPinnedORGs_MouseEnter"
VerticalAlignment="Top" Width="158" Name="ui_lsbPinnedORGs" ItemContainerStyle="{StaticResource PinnedListBoxItem}">
<ListBox.ItemTemplate>
<HierarchicalDataTemplate>
<Label Content="{Binding Path=ORG.Acronym, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}" />
</HierarchicalDataTemplate>
</ListBox.ItemTemplate>
</ListBox>
:現在のテンプレートに
UPDATE
それとも永久に変更するのですか? –
クリックして、一度選択しないとデフォルト(黒)に戻ります。 –