这是我的对象模型
private class ShellItem
{
public string Name { get; set; }
public string Command { get; set; }
public List<ShellMenu> ShellMenus { get; private set; }
public ShellItem()
{
ShellMenus = new List<ShellMenu>();
}
}
public class ShellMenu
{
public string ExtName;
public string KeyName;
public string FileType;
public string MenuName { get; set; }
public string Command { get; set; }
}
这是我的 xaml。
<ListView Name="listViewRightClick" HorizontalAlignment="Stretch" Height="Auto" Margin="10,10,26.667,107.667" VerticalAlignment="Stretch" Width="Auto">
<ListView.View>
<GridView>
<GridViewColumn Width="200" Header="Name" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Width="600" Header="Command" DisplayMemberBinding="{Binding Command}"/>
<GridViewColumn Width="200" Header="FileTypes">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding ShellMenus}"
SelectedValue="{Binding MenuName}"
Margin="-6, 0, -6, 0"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
我的问题不是显示 shellMenu 的 MenuName,而是在组合框的每个项目上显示 MyNamespace.ShellMenu。