我有这个 XAML 代码
<ListView Name="_lvContacts" ItemsSource="{Binding AccountPhonesList}"
<ListView.View>
<GridView>
<GridViewColumn Header="{Binding Path=ColumnHeader1}" DisplayMemberBinding="{Binding Path=Home}" Width="70" />
<GridViewColumn Header="{Binding Path=ColumnHeader2}" DisplayMemberBinding="{Binding Path=Office}" Width="70" />
<GridViewColumn Header="{Binding Path=ColumnHeader3}" DisplayMemberBinding="{Binding Path=Mobile}" Width="70" />
<GridViewColumn Header="{Binding Path=ColumnHeader4}" DisplayMemberBinding="{Binding Path=Other}" Width="70" />
<GridViewColumn Header="{Binding Path=ColumnHeader5}" DisplayMemberBinding="{Binding Path=Email}" Width="70" />
</GridView>
</ListView.View>
</ListView>
这是背后的代码
for (int i = 0; i < _lvContacts.Items.Count; i++)
{
string header = _lvContacts.Items[i].ToString();
MyFunction(header);
}
如何从 ListView 获取 GridViewColumn 标题?我试图从 ItemSources 获取 GridView,但这已被集合使用!我不知道我还能说什么。
我希望这是可以理解的。