public DefaultThreadListViewViewModel(int pageNo, int forumId, ListView leftListView, CommandBar leftCommandBar, Action openCreateThreadPanel, Action beforeLoad, Action afterLoad, Action noDataNotice) { _forumId = forumId; _leftListView = leftListView; _leftListView.SelectionMode = ListViewSelectionMode.Single; _leftListView.ItemsSource = null; _leftListView.ItemTemplateSelector = App.Current.Resources["threadListItemTemplateSelector"] as DataTemplateSelector; _leftListView.ItemContainerStyle = App.Current.Resources["ThreadItemContainerStyle"] as Style; _leftCommandBar = leftCommandBar; _leftCommandBar.Visibility = Visibility.Visible; _leftCommandBar.PrimaryCommands.Clear(); _leftCommandBar.SecondaryCommands.Clear(); _beforeLoad = beforeLoad; _afterLoad = afterLoad; _noDataNotice = noDataNotice; _ds = new ThreadListService(); LoadData(pageNo, _forumId); RefreshThreadCommand = new DelegateCommand(); RefreshThreadCommand.ExecuteAction = (p) => { _ds.ClearThreadData(_forumId); LoadData(1, _forumId); }; var btnAdd = new AppBarButton { Icon = new FontIcon { Glyph = "\uE104" }, Label = "发表新贴" }; btnAdd.Click += (s, e) => openCreateThreadPanel(); _leftCommandBar.PrimaryCommands.Add(btnAdd); var btnRefresh = new AppBarButton { Icon = new FontIcon { Glyph = "\uE895" }, Label = "刷新" }; btnRefresh.Command = RefreshThreadCommand; _leftCommandBar.PrimaryCommands.Add(btnRefresh); var categories = SendService.GetCategory(_forumId); if (categories != null) { var btnSelectLabel = new AppBarButton { Icon = new FontIcon { Glyph = "\uE169" }, Label = "按标签浏览" }; var menuFlyout = new MenuFlyout(); foreach (var cat in categories) { menuFlyout.Items.Add(CreateMenuFlyoutItem(cat[0], Convert.ToInt32(cat[1]))); } btnSelectLabel.Flyout = menuFlyout; _leftCommandBar.PrimaryCommands.Add(btnSelectLabel); } var _btnSort = new AppBarToggleButton { Icon = new SymbolIcon(Symbol.Sort), Label = "\u2601 按发布时间倒序排列(限当前版块)" }; _btnSort.IsChecked = RoamingSettingsService.GetOrderByDateline(_forumId); _btnSort.Checked += (s, e) => { RoamingSettingsService.SetOrderByDateline(_forumId, true); _ds.ClearThreadData(_forumId); LoadData(1, _forumId); }; _btnSort.Unchecked += (s, e) => { RoamingSettingsService.SetOrderByDateline(_forumId, false); _ds.ClearThreadData(_forumId); LoadData(1, _forumId); }; _leftCommandBar.SecondaryCommands.Add(_btnSort); }