2009-05-15 34 views

答えて

1

これはトリックを行う必要がありますあなたはIsSelectedプロパティのトリガーとItemContainerStyleを使用する必要があり、かつトリガーにあなたはBackgroundプロパティに

+0

私はトリガーについてはしません。それのコードを投稿することができます。 –

+0

返事をありがとう。私はウルの助けを借りて解決策を得た。 –

+0

回答を承認済みとしてマークすることを忘れないでください。 –

1

をセッターを置く:

<Window x:Class="StackOverflowTests.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Window1" x:Name="window1" Height="300" Width="300"> 
    <Window.Resources> 
     <!-- Specifies the Selection style of ListBoxItems. This changes the forced underlay colors from gray to transparent. --> 
     <Style TargetType="ListBoxItem"> 
      <Style.Resources> 
       <!-- This is the color used if the item is selected and the listbox has focus --> 
       <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red"/> 
      </Style.Resources> 
     </Style> 
    </Window.Resources> 
    <Grid> 
     <StackPanel Orientation="Vertical"> 
      <ListBox> 
       <ListBoxItem Content="Item 1" /> 
       <ListBoxItem Content="Item 2" /> 
       <ListBoxItem Content="Item 3" /> 
       <ListBoxItem Content="Item 4" /> 
       <ListBoxItem Content="Item 5" /> 
       <ListBoxItem Content="Item 6" /> 
       <ListBoxItem Content="Item 7" /> 
       <ListBoxItem Content="Item 8" /> 
       <ListBoxItem Content="Item 9" /> 
       <ListBoxItem Content="Item 10" /> 
      </ListBox> 
     </StackPanel>  
    </Grid> 
</Window> 
関連する問題