2009-05-15 3 views

답변

1

당신은에 isSelected 속성에 트리거가있는 ItemContainerStyle을 사용해야하며, 트리거에 당신이 트릭해야

+0

입니다. 그 코드를 게시 할 수 있습니다. –

+0

답장을 보내 주셔서 감사합니다. 나는 ur 도움으로 해결책을 얻었다. –

+0

답변을 수락 된 것으로 표시하는 것을 잊지 마세요. –

1

Background 속성에 세터를 넣어 :

<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>