Exemple #1
0
        public Serials()
        {
            InitializeComponent();
            var serial = new SerialsViewModel();

            DataContext = serial;
        }
Exemple #2
0
        public SerialsPage()
        {
            InitializeComponent();
            NameScope.SetNameScope(dgcm, NameScope.GetNameScope(this));
            VM = MainViewModel.Default.SerialsViewModel;
            VM.ConfirmationShow = (s1, s2) =>
            {
                var dialog = new ModernDialog
                {
                    Title   = s1,
                    Content = s2
                };

                MessageBoxResult result = MessageBoxResult.Cancel;
                var yesButton           = new Button()
                {
                    Content = "Да",
                    Margin  = new Thickness(2, 0, 2, 0)
                };
                yesButton.Click += (o, ea) =>
                {
                    result = MessageBoxResult.Yes;
                    dialog.Close();
                };
                var noButton = new Button()
                {
                    Content    = "Нет",
                    Margin     = new Thickness(2, 0, 2, 0),
                    FontWeight = FontWeights.Bold,
                    IsDefault  = true
                };
                noButton.Click += (o, ea) =>
                {
                    result = MessageBoxResult.No;
                    dialog.Close();
                };
                dialog.Buttons = new Button[] { yesButton, noButton };


                dialog.ShowDialog();

                if (result == MessageBoxResult.Yes)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
            VM.TextSearchStarted = () =>
            {
                tbFilter.Focus();
                Keyboard.Focus(tbFilter);
            };

            dg.Focus();
            Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.ContextIdle,
                new Action(() => Keyboard.Focus(dg)));
            dg.SyncSortWithView();

            VM.Refreshed = () => dg.ScrollToCurrentItem();

            DataContext = VM;
        }