专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > .NET Framework

关于ListView的ItemContainerStyle的样式有关问题

发布时间:2011-06-23 14:46:31 文章来源:www.iduyao.cn 采编人员:星星草
关于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>
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: