Menu.Pages填充了这个:
this.Menu = new Menu()
{
Pages = new List<Page>()
{
new Page() {
Title = "ergre",
URI = "rgerg"
},
new Page() {
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 :( ?
}
但是,页面变量不包含页面。如何正确连接对象......
答案 0 :(得分:0)
我忘了放置CommandParamter属性。以下解决了这个问题!
vector<vector<int> > A(m)