0

Here is my object model

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; }

}

Here is my 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>

My problem is instead of showing MenuName of shellMenu it shows MyNamespace.ShellMenu on every item of combobox.

4

2 に答える 2

4

SelectedValue選択のみDisplayMemberPathについて、表示に使用します。

DisplayMemberPath="MenuName"
于 2012-08-29T11:08:52.487 に答える
0

DisplayMemberPathで指定する必要がありますComboBox

<ComboBox 
    ItemsSource="{Binding ShellMenus}"
    SelectedValue="{Binding MenuName}"
    DisplayMemberPath="MenuName"
    Margin="-6, 0, -6, 0"/> 
于 2012-08-29T11:10:23.907 に答える