C# ViewModel中的RelayCommand不包含XAML命令中绑定的Listbox对象

C# ViewModel中的RelayCommand不包含XAML命令中绑定的Listbox对象,c#,xaml,mvvm-light,C#,Xaml,Mvvm Light,菜单。页面中充满以下内容: this.Menu = new Menu() { Pages = new List<Page>() { new Page() { Title = "ergre", URI = "rgerg" }, new

菜单。页面中充满以下内容:

        this.Menu = new Menu()
        {
            Pages = new List<Page>()
            {
                new Page() {
                    Title = "ergre",
                    URI = "rgerg"
                },
                new Page() {
                    Title = "herth",
                    URI = "wefwe"
                }
            }
        };
this.Menu=new Menu()
{
Pages=新列表()
{
新页(){
Title=“ergre”,
URI=“rgerg”
},
新页(){
Title=“herth”,
URI=“wefwe”
}
}
};
我有以下XAML:

    <ListBox Grid.Column="0"
             Grid.Row="1"
             x:Name="Pages"
             ItemsSource="{Binding Menu.Pages}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <Button Command="{Binding ElementName=Pages, Path=DataContext.ButtonCommand_LoadGagPage}">
                        <TextBlock Text="{Binding Title}"></TextBlock>
                    </Button>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

绑定到按钮的命令将正确触发以下方法:

...    
ButtonCommand_LoadGagPage = new RelayCommand<Page>((param) => ButtonCommand_ExecuteLoadGagPage(param));    
...


public RelayCommand<Page> ButtonCommand_LoadGagPage
{
    get;
    private set;
}

public void ButtonCommand_ExecuteLoadGagPage(Page page)
{
    // page is null :( ?
}
。。。
ButtonCommand_LoadGagPage=新的RelayCommand((参数)=>ButtonCommand_ExecuteLoadGagPage(参数));
...
公共中继命令按钮命令和加载页面
{
得到;
私人设置;
}
公共作废按钮命令和执行器加载页面(第页)
{
//页面为空:(?)?
}

但是,页面变量不包含页面。如何正确连接对象…

我忘记将CommandParameter属性放置在上。以下解决了该问题

<Button Command="{Binding ElementName=Pages, Path=DataContext.ButtonCommand_LoadGagPage}"
                            CommandParameter="{Binding}">