怎么wpf中用数据触发器,动态的改变ListView中的背景颜色
xaml:
[code=C#]
<ListView x:Name="lvData">
<ListView.ContextMenu>
<ContextMenu Opened="cmRight_Opened" Name="cmRight">
<MenuItem Name="start1" Header="启动" Click="start_Click"></MenuItem>
<MenuItem Name="stop1" Header="停止" Click="stop_Click"></MenuItem>
<MenuItem Name="pause1" Header="暂停" Click="pause_Click"></MenuItem>
<MenuItem Name="resume1" Header="恢复" Click="resume_Click"></MenuItem>
<MenuItem Header="重新启动"></MenuItem>
<Separator/>
<MenuItem Header="所有任务">
<MenuItem Name="start" Header="启动" Click="start_Click"></MenuItem>
<MenuItem Name="stop" Header="停止" Click="stop_Click"></MenuItem>
<MenuItem Name="pause" Header="暂停" Click="pause_Click"></MenuItem>
<MenuItem Name="resume" Header="恢复" Click="resume_Click"></MenuItem>
<MenuItem Header="重新启动"></MenuItem>
</MenuItem>
<Separator/>
<MenuItem Name="refresh" Header="刷新" Click="refresh_Click"></MenuItem>
</ContextMenu>
</ListView.ContextMenu>
<!--<SnippetItemContainerStyle>-->
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}" >
<Setter Property="Template"
Value="{StaticResource Default}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding XPath=Name}" Value="System">
<Setter Property="Template"
Value="{StaticResource StronglyRecommended}"/>
</DataTrigger>
<DataTrigger Binding="{Binding XPath=CPU}" Value="00">
<Setter Property="Template"
Value="{StaticResource Recommended}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<!--</SnippetItemContainerStyle>-->
<!--<SnippetGridView>-->
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource MyHeaderStyle2}">
<GridViewColumn Header="进程ID"
DisplayMemberBinding="{Binding XPath=Handle}"
Width="100"/>
<GridViewColumn Header="名称"
DisplayMemberBinding="{Binding XPath=Name}"
Width="80"/>
<GridViewColumn Header="用户名"
DisplayMemberBinding="{Binding XPath=CSName}"
Width="80" />
<GridViewColumn Header="线程数"
DisplayMemberBinding="{Binding XPath=ThreadCount}"
Width="100"/>
<GridViewColumn Header="会话ID"
DisplayMemberBinding="{Binding XPath=SessionId}"
Width="100"/>
<GridViewColumn Header="内存使用"
DisplayMemberBinding="{Binding XPath=WorkingSetSize}"
Width="100"/>
<GridViewColumn Header="高峰内存使用"
DisplayMemberBinding="{Binding XPath=PeakWorkingSetSize}"
Width="100"/>
<GridViewColumn Header="CPU"
DisplayMemberBinding="{Binding XPath=CPU}"
Width="100"/>
<GridViewColumn Header="CPU时间"
DisplayMemberBinding="{Binding XPath=CPUTime}"
Width="100"/>
<GridViewColumn Header="描述"
DisplayMemberBinding="{Binding XPath=Description}"
Width="100"/>
<GridViewColumn Header="IO"
DisplayMemberBinding="{Binding XPath=OtherOperationCount}"
Width="100"/>
</GridView>
</ListView.View>
<!--</SnippetGridView>-->
</ListView>
[/code]
后台代码
/// <summary>
/// 得到所有的进程信息,并数据绑定
/// </summary>
public void GetAllProcess(string ip, string userName, string password)
{
IList<Process> processes = ProcessManager.GetAllProcess(ip, userName, password);
lvData.ItemsSource = processes;
}
怎么就触发不了呢,请大侠们帮忙?