Beispiel #1
0
        private void ShowImages(ChildWindowEventArg args)
        {
            var childWindow = new ChildWindow
            {
                Content     = args.View,
                DataContext = args.ViewModel
            };

            PhotoViewModel photoViewModel = args.ViewModel as PhotoViewModel;
            Action         hideWindows    = () => childWindow.Hide();

            if (photoViewModel != null)
            {
                photoViewModel.HideWindow = () => hideWindows();
            }

            Action <object, KeyEventArgs> childWindowKeyUp =
                (sender, e) =>
            {
                if (e.Key == Key.Escape)
                {
                    hideWindows();
                }
            };

            childWindow.KeyUp += (sender, e) => childWindowKeyUp(sender, e);
            Action <ChildWindowScaleEventArgs> scaleCildWindow =
                x => childWindow.WindowState = x.FullScale ? WindowState.Maximized : WindowState.Normal;
            Func <ChildWindowScaleEventArgs, bool> canScaleCildWindow = x => x != null;

            Messenger?.Register(CommandName.SetPhotoWindowState, scaleCildWindow, canScaleCildWindow);
            childWindow.ShowDialog();
            Messenger?.Unregister(CommandName.SetPhotoWindowState);
            childWindow.Close();
        }
        public static void CreateChildWindow()
        {
            var view      = new ChildWindow();
            var viewModel = new ChildWindowViewModel();

            view.DataContext = viewModel;
            view.ShowDialog();
        }
Beispiel #3
0
        private void AddRecipe_Click_1(object sender, RoutedEventArgs e)
        {
            ChildWindow chldWin = new ChildWindow();

            chldWin.Content = new AddRecipeUC();
            chldWin.Title   = "Додавання рецепту";
            chldWin.ShowDialog();
            dgCatalogUC.DataContext = catalogViewModel.Catalog.OrderBy(c => c.Name);
        }
        private void btnPushMe_Click_1(object sender, RoutedEventArgs e)
        {
            ChildWindow child = new ChildWindow();

            bool? resDiag = child.ShowDialog();

            if (resDiag.HasValue && resDiag.Value)
            {
                lbl1.Content = child.txtBox1Text;
            }
        }
Beispiel #5
0
 public void ShowDialog(Type viewModel, ChildWindow dialog, Action <bool, object> Onclose = null)
 {
     DialogWindow = dialog;
     ViewModel    = viewModel;
     //dialog.Title = viewModel.Title;
     dialog.DataContext   = ViewModel;
     dialog.Owner         = Application.Current.MainWindow;
     dialog.ShowInTaskbar = false;
     dialog.Closed       += Dialog_Closed;
     (dialog.DataContext as ViewModelBase).OnCloseAction = Onclose;
     dialog.ShowDialog();
 }
        public static void WriteAndRunXAML(string componentCode)
        {
            string path = "code.xaml";

            using (StreamWriter w = new StreamWriter(path))
            {
                w.Write(componentCode);
            }

            StreamReader sr   = new StreamReader(path);
            StackPanel   root = XamlReader.Load(sr.BaseStream) as StackPanel;

            //UIElement item = (UIElement)(XamlReader.Parse(componentCode));

            ChildWindow child = new ChildWindow();

            //child.Preview.Children.Add(item);
            //child.Preview = root;
            child.Content = root;
            child.ShowDialog();
        }
        private void MenuItem_Click_Option(object sender, RoutedEventArgs e)
        {
            reset();

            ChildWindow option = new ChildWindow(imageBG);
            option.ShowDialog();
        }
Beispiel #8
0
        private void OnConfigCommandMessage(ConfigCommandMessage message)
        {
            var window = new ChildWindow();
            var contentControl = new NewEditServer();
            contentControl.DataContext = new EditServerDetailViewModel(message.Server);
            window.Content = contentControl;
            window.SizeToContent = SizeToContent.WidthAndHeight;
            window.Topmost = true;
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.ResizeMode = ResizeMode.NoResize;
            window.Title = "Edit Server";

            Messenger.Default.Register<CloseEditServerMessage>(this, (m) =>
            {
                window.DialogResult = false;
                window.Close();
            });

            window.ShowDialog();
            Messenger.Default.Unregister<CloseEditServerMessage>(this);
        }