日期:2014-05-20  浏览次数:20889 次

关于ListView的ItemContainerStyle的样式问题
我的ListView的的ItemSource是通过MVVM方式绑定的(<ListView Name="ListViewEvent" ItemsSource="{Binding RecvEventViewModelCollection}">),这样每个GridColumn绑定源中的每个项(DisplayMemberBinding="{Binding Path=RecvTime}") ,现在的问题是,我想重新实现每个ListViewItem的样式,
  <Style x:Key="Custom1ListViewItemStyle" TargetType="{x:Type ListViewItem}">
  <Style.Resources>
  <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Yellow"/>
  <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color=" Red"/>
  </Style.Resources>
  <Setter Property="Panel.Background" Value="LightBlue"/>
  <Setter Property="Foreground" Value="White"></Setter>
  <Setter Property="Focusable" Value="False"></Setter>
  <Setter Property="Control.Template">
  <Setter.Value>
  <ControlTemplate TargetType="ListViewItem">
  <Border BorderThickness="{TemplateBinding Border.BorderThickness}" 
  BorderBrush="{TemplateBinding Border.BorderBrush}" 
  Background="{TemplateBinding Panel.Background}" 
  Name="Bd" 
  SnapsToDevicePixels="True">
  <ContentPresenter/>
  </Border>
  <ControlTemplate.Triggers>
  <Trigger Property="Selector.IsSelected" Value="True">
  <Setter Property="Panel.Background" TargetName="Bd">
  <Setter.Value>
  <DynamicResource ResourceKey="{x:Static SystemColors.HighlightBrushKey}" />
  </Setter.Value>
  </Setter>
  <Setter Property="TextElement.Foreground">
  <Setter.Value>
  <DynamicResource ResourceKey="{x:Static SystemColors.HighlightTextBrushKey}" />
  </Setter.Value>
  </Setter>
  </Trigger>
  <MultiTrigger>
  <MultiTrigger.Conditions>
  <Condition Property="Selector.IsSelected" Value="True"/>
  <Condition Property="Selector.IsSelectionActive" Value="False"/>
  </MultiTrigger.Conditions>
  <Setter Property="Panel.Background" TargetName="Bd">
  <Setter.Value>
  <DynamicResource ResourceKey="{x:Static SystemColors.ControlBrushKey}" />
  </Setter.Value>
  </Setter>
  <Setter Property="TextElement.Foreground">
  <Setter.Value>