大家好,我是 WPF 新手,我使用列表视图呈现为网格视图。我有一个图像列,我通过绑定路径为其设置了一个值。现在的问题是我需要根据条件更改图像的路径。如果条件为真,我需要图像的路径不同。如果为假,我将其更改为另一条路径。这可以逐行完成吗?下面是我的列表视图。请帮忙
<ListView Name="LstGrd" Margin="0,105,0,138">
<ListView.View>
<GridView >
<GridViewColumn Header=" Name" Width="120" DisplayMemberBinding="{Binding Path=Name}" />
<GridViewColumn Header=" Address" Width="250" DisplayMemberBinding="{Binding Path=Address}" />
<GridViewColumn Header=" City" Width="50" DisplayMemberBinding="{Binding Path=City}" />
<GridViewColumn Header=" State" Width="75" DisplayMemberBinding="{Binding Path=State}" />
<GridViewColumn Header=" PostalCode" Width="75" DisplayMemberBinding="{Binding Path=PostalCode}" />
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Width="16" Name="Test" Height="16" Source="{Binding Path=ImagePath,Mode=TwoWay}"/>
<TextBlock Text="Status"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>