示例#1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ControlGameView = Template.FindName("PART_ControlGameView", this) as Control;
            if (ControlGameView != null)
            {
                BindingTools.SetBinding(ControlGameView,
                                        Control.DataContextProperty,
                                        mainModel,
                                        nameof(DesktopAppViewModel.SelectedGameDetails));
            }

            ListGames = Template.FindName("PART_ListGames", this) as ExtendedListBox;
            if (ListGames != null)
            {
                SetListGamesBinding();
                BindingTools.SetBinding(ListGames,
                                        ExtendedListBox.SelectedItemProperty,
                                        mainModel,
                                        nameof(DesktopAppViewModel.SelectedGame),
                                        BindingMode.TwoWay);
                BindingTools.SetBinding(ListGames,
                                        ExtendedListBox.SelectedItemsListProperty,
                                        mainModel,
                                        nameof(DesktopAppViewModel.SelectedGamesBinder),
                                        BindingMode.TwoWay);

                ScrollToSelectedBehavior.SetEnabled(ListGames, true);

                ListGames.InputBindings.Add(new KeyBinding(mainModel.EditSelectedGamesCommand, mainModel.EditSelectedGamesCommand.Gesture));
                ListGames.InputBindings.Add(new KeyBinding(mainModel.RemoveSelectedGamesCommand, mainModel.RemoveSelectedGamesCommand.Gesture));
                ListGames.InputBindings.Add(new KeyBinding(mainModel.StartSelectedGameCommand, mainModel.StartSelectedGameCommand.Gesture));
            }
        }
示例#2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ControlGameView = Template.FindName("PART_ControlGameView", this) as Control;
            if (ControlGameView != null)
            {
                BindingTools.SetBinding(ControlGameView,
                                        Control.DataContextProperty,
                                        mainModel,
                                        nameof(DesktopAppViewModel.SelectedGameDetails));
            }

            ListGames = Template.FindName("PART_ListGames", this) as ExtendedListBox;
            if (ListGames != null)
            {
                SetListGamesBinding();
                BindingTools.SetBinding(ListGames,
                                        ExtendedListBox.SelectedItemProperty,
                                        mainModel,
                                        nameof(DesktopAppViewModel.SelectedGame),
                                        BindingMode.TwoWay);
                BindingTools.SetBinding(ListGames,
                                        ExtendedListBox.SelectedItemsListProperty,
                                        mainModel,
                                        nameof(DesktopAppViewModel.SelectedGamesBinder),
                                        BindingMode.TwoWay);

                ScrollToSelectedBehavior.SetEnabled(ListGames, true);

                if (!DesignerProperties.GetIsInDesignMode(this))
                {
                    ListGames.InputBindings.Add(new KeyBinding(mainModel.EditSelectedGamesCommand, mainModel.EditSelectedGamesCommand.Gesture));
                    ListGames.InputBindings.Add(new KeyBinding(mainModel.RemoveSelectedGamesCommand, mainModel.RemoveSelectedGamesCommand.Gesture));
                    ListGames.InputBindings.Add(new KeyBinding(mainModel.StartSelectedGameCommand, mainModel.StartSelectedGameCommand.Gesture));
                }

                ListGames.SelectionMode = SelectionMode.Extended;
                VirtualizingPanel.SetCacheLengthUnit(ListGames, VirtualizationCacheLengthUnit.Item);
                VirtualizingPanel.SetCacheLength(ListGames, new VirtualizationCacheLength(5));
                VirtualizingPanel.SetScrollUnit(ListGames, ScrollUnit.Pixel);
                VirtualizingPanel.SetIsVirtualizingWhenGrouping(ListGames, true);
                VirtualizingPanel.SetVirtualizationMode(ListGames, VirtualizationMode.Recycling);
            }

            ControlTemplateTools.InitializePluginControls(
                mainModel.Extensions,
                Template,
                this,
                SDK.ApplicationMode.Desktop,
                mainModel,
                $"{nameof(DesktopAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}");
        }