2016-06-15 24 views
0

私はこのWPFのListBoxの選択の背景色の変更

<ListBox.ItemContainerStyle> 
       <Style TargetType="ListBoxItem"> 
        <Style.Triggers> 
         <Trigger Property="IsSelected" Value="True" > 
          <Setter Property="FontWeight" Value="Bold" /> 
          <Setter Property="Background" Value="Red" /> 
         </Trigger> 
        </Style.Triggers> 
        <Style.Resources> 
         <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> 
         <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" /> 
        </Style.Resources> 
       </Style> 
      </ListBox.ItemContainerStyle> 

を試みたが、それは仕事をdidn`tの。誰かが私を助けることができますか?

答えて

0

あなたはちょうど間違った場所にいると思います。これを試して。

<ListBox.ItemContainerStyle> 
      <Style TargetType="ListBoxItem"> 
       <Style.Triggers> 
        <Trigger Property="IsSelected" Value="True" > 
         <Setter Property="FontWeight" Value="Bold" /> 
         <Setter Property="Background" Value="Red" /> 
        </Trigger> 
       </Style.Triggers> 
      </Style> 
     </ListBox.ItemContainerStyle> 
     <ListBox.Resources> 
      <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> 
      <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" /> 
     </ListBox.Resources> 
+2

あなたは本当にこのコードは動作するはずです理由として、いくつかの説明を追加する必要があります - あなたはまた、コード自体 にコメントを追加することができます - 現在の形で、それがコミュニティの残りの部分を助けることができる任意の説明を提供しません。あなたが解決するために/答えたことを理解する。 – ishmaelMakitla

関連する問題