我有一个这样定义的列表视图:
<ListView Height="234.522" Name="chartListView" Width="260" SelectionChanged="chartListView_SelectionChanged" HorizontalAlignment="Left" Margin="251,38,0,38">
<ListView.View>
<GridView>
<GridViewColumn Header="op1" DisplayMemberBinding="{Binding op1}" Width="50"/>
<GridViewColumn Header="op2" DisplayMemberBinding="{Binding op2}" Width="50"/>
<GridViewColumn Header="op3" DisplayMemberBinding="{Binding op3}" Width="50"/>
<GridViewColumn Header="op4" DisplayMemberBinding="{Binding op4}" Width="50"/>
<GridViewColumn Header="op5." DisplayMemberBinding="{Binding op5}" Width="50"/>
</GridView>
</ListView.View>
</ListView>
我使用以下内容添加数据:
chartListView.Items.Add(new {
op1 = "test1", op2 = "test2", op3 = "test3", op4 = "test4", op5 = "test5" });
如何访问选定的项目之一,以便我可以查看列具有的值(op3
例如)?以下代码显示了所有值,但我只想查看op3
.
MessageBox.Show(chartListView.SelectedItem.ToString());