2011-02-24 6 views
2

Microsoft Surface SDK를 사용하고 있으며 선택한 항목의 스타일을 지정하는 데 문제가 있습니다.SurfaceListBox 선택한 항목 템플릿

<s:SurfaceListBox Name="listy" Background="Transparent" 
        FontSize="50" Foreground="White" BorderBrush="White" 
        HorizontalContentAlignment="Center" 
        Margin="5,5,5,100" SelectionMode="Single"> 
    <s:SurfaceListBox.ItemTemplate> 
     <DataTemplate> 
      <TextBlock Text="{Binding}" Foreground="White" /> 
     </DataTemplate> 
    </s:SurfaceListBox.ItemTemplate> 
    <s:SurfaceListBox.ItemContainerStyle> 
     <Style TargetType="ListBoxItem"> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="{x:Type ListBoxItem}"> 
         <ContentPresenter HorizontalAlignment="Center" /> 
         <ControlTemplate.Triggers> 
          <Trigger Property="IsSelected" Value="True"> 
           <Setter Property="Background" Value="Grey" /> 
          </Trigger> 
         </ControlTemplate.Triggers> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
    </s:SurfaceListBox.ItemContainerStyle> 
</s:SurfaceListBox> 

을하지만 실패하고 모든 인터넷이에 대한 튜토리얼이 없습니다 - 내가 시간 검색은 :

지금까지 내가 가지고있다.

도움 주셔서 감사합니다.

+1

봐에 BorderContentPresenter을 감고을 대상으로 할 수있다. 동일한 코드가 Surface에서 작동합니다. –

답변

0

문제는 그 배경을 사용하는 것이 없다고 생각합니다. 당신은 일반 목록 상자 컨트롤을 스타일링에 튜토리얼 트리거

<ControlTemplate TargetType="{x:Type s:SurfaceListBoxItem}"> 
    <Border x:Name="Border"> 
     <ContentPresenter HorizontalAlignment="Center" /> 
    </Border> 
    <ControlTemplate.Triggers> 
     <Trigger Property="IsSelected" Value="True"> 
      <Setter TargetName="Border" Property="Background" Value="Gray"/> 
     </Trigger> 
    </ControlTemplate.Triggers> 
</ControlTemplate>