【发布时间】:2015-03-31 06:34:15
【问题描述】:
我目前在集合视图上进行数据绑定以显示我的所有按钮。
但是,由于我的收藏列表中有超过 24 项,我想在同一页面上添加四个按钮(开胃菜、早餐、午餐、晚餐),并根据我单击的一个进行过滤。这样我一次只显示其中的几个选项。
我应该在 ViewModel 中处理这个问题吗?或者这应该是网页浏览的责任吗?
MenuItem 类:
public enum type
{
Appetizer,
Breakfast,
Lunch,
Dinner
};
class MenuItem
{
//stuff
}
菜单项页面:
public sealed partial class MenuItemsPage : Page
{
public MenuItemsPage()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string tableName = e.Parameter as string;
this.DataContext = new MenuPageVM(tableName); //this returns List<MenuItem> 24 items. All 4 types of MenuItems
}
}
}
XAML:
<CollectionViewSource x:Key="MenuItemsCollectionViewSource" Source="{Binding MenuItems}"/>
<GridView SelectionMode="None"
x:Name="menuGrid" ItemsSource="{Binding Mode=OneTime, Source={StaticResource MenuItemsCollectionViewSource}}" Margin="256,113,320,184"
ItemTemplate="{StaticResource MenuButtonTemplate}"/>
【问题讨论】: