当前位置: 首页>>代码示例>>C#>>正文


C# Window.ShowDialog方法代码示例

本文整理汇总了C#中System.Windows.Window.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# Window.ShowDialog方法的具体用法?C# Window.ShowDialog怎么用?C# Window.ShowDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Window的用法示例。


在下文中一共展示了Window.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowDialog

    public void ShowDialog()
    {
      object view = Context.Container.ResolveView(this.GetType());
      if (view != null)
      {
        if (view is Window)
        {
          Window window = (Window)view;
          window.DataContext = this;
          window.ShowDialog();
        }
        else if (view is FrameworkElement)
        {
          Window window = new Window();
          window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
          window.ResizeMode = ResizeMode.NoResize;
          window.SizeToContent = SizeToContent.WidthAndHeight;
          window.ShowInTaskbar = false;
          window.Topmost = true;

          FrameworkElement control = (FrameworkElement)view;
          window.Height = control.Height;
          window.Width = control.Width;
          window.Content = control;
          control.DataContext = this;
          window.ShowDialog();
        }
      }
    }
开发者ID:krdbigsa,项目名称:NuGetPackageExplorer.Plugins,代码行数:29,代码来源:ViewModelBase.cs

示例2: CreateWindowInstance

        private static void CreateWindowInstance(ControlTestRequest request, ManualResetEventSlim evt) {
            try {
                Window = new Window();

                if (Screen.AllScreens.Length == 1) {
                    Window.Left = 0;
                    Window.Top = 50;
                } else {
                    Screen secondary = Screen.AllScreens.FirstOrDefault(x => !x.Primary);
                    Window.Left = secondary.WorkingArea.Left;
                    Window.Top = secondary.WorkingArea.Top + 50;
                }

                Window.Width = 800;
                Window.Height = 600;

                Component = Activator.CreateInstance(request.ControlType);
                if (Component is Control) {
                    Control = Component as Control;
                } else {
                    Control = Component.GetType().GetProperty("Control").GetValue(Component) as Control;
                }

                Window.Title = "Control - " + request.ControlType;
                Window.Content = Control;
            } finally {
                evt.Set();
            }

            Window.Topmost = true;
            Window.ShowDialog();
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:32,代码来源:ControlWindow.cs

示例3: GenericShowDialog

 private void GenericShowDialog(Window window)
 {
     this.Hide();
     window.Owner = this;
     window.ShowDialog();
     this.Close();
 }
开发者ID:akappel,项目名称:screentogif,代码行数:7,代码来源:Startup.xaml.cs

示例4: ShowDialog

        private void ShowDialog(Window dialog, Action<bool> onClosed, bool subDialog)
        {
            dialog.Closed += (sender, args) =>
            {
                _WindowStack.Pop();

                if (onClosed != null)
                {
                    onClosed(dialog.DialogResult ?? false);
                }
            };

            if (subDialog && _WindowStack.Count > 0)
            {
                dialog.Owner = _WindowStack.Peek();
                dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                var mask = new SolidColorBrush(Colors.White);
                mask.Opacity = 0.5;

                _WindowStack.Peek().OpacityMask = mask;
            }

            dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            _WindowStack.Push(dialog);

            dialog.ShowDialog();

            if (_WindowStack.Count > 0)
            {
                _WindowStack.Peek().OpacityMask = null;
            }
        }
开发者ID:hamleyPaw,项目名称:ModelWPF,代码行数:34,代码来源:InteractionService.cs

示例5: OnAddView

    private void OnAddView(object sender, ExecutedRoutedEventArgs e)
    {
      try
      {

        if (Bcfier.SelectedBcf() == null)
          return;
        var issue = e.Parameter as Markup;
        if (issue == null)
        {
          MessageBox.Show("No Issue selected", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
          return;
        }

        var addView = new AddView(issue, Bcfier.SelectedBcf().TempPath);
        var win = new Window
        {
          Content = addView,
          Title = "Add View",
          SizeToContent = SizeToContent.WidthAndHeight,
          WindowStartupLocation = WindowStartupLocation.CenterScreen
        };
        win.ShowDialog();
        if (win.DialogResult.HasValue && win.DialogResult.Value)
          Bcfier.SelectedBcf().HasBeenSaved = false;

      }
      catch (System.Exception ex1)
      {
        MessageBox.Show("exception: " + ex1);
      }
    }
开发者ID:whztt07,项目名称:BCFier,代码行数:32,代码来源:MainWindow.xaml.cs

示例6: DisplayClosingDialog

 void DisplayClosingDialog(Window dlgWnd)
 {
     if (dlgWnd == null)
         return;
     CloseIfUnchanged();
     dlgWnd.ShowDialog();
 }
开发者ID:JoeGilkey,项目名称:RadioLog,代码行数:7,代码来源:SettingsView.xaml.cs

示例7: showWindow

 public void showWindow(object viewModel)
 {
     var window = new Window();
     window.Content = viewModel;
     window.Owner = Application.Current.MainWindow;
     window.ShowDialog();
 }
开发者ID:siddhujz,项目名称:PeopleSearch,代码行数:7,代码来源:WindowService.cs

示例8: ReactiveProperty_Click

 private void ReactiveProperty_Click(object sender, RoutedEventArgs e)
 {
     Window window = new Window { Content = new UsingReactivePropertyView()};
     window.Height = 400;
     window.Width = 500;
     window.ShowDialog();
 }
开发者ID:SneshPrajapati,项目名称:ICommandDemo,代码行数:7,代码来源:MainWindow.xaml.cs

示例9: Main

    private static void Main() {
      var builder = new ContainerBuilder();

      builder.RegisterModule<Profiler>();

      builder.RegisterType<List<string>>().As<IEnumerable<string>>();

      builder.RegisterGeneric(typeof(BinaryTree<>)).As(typeof(ITree<>));
      builder.Register(c => new TreeWrapper(c.Resolve<ITree<int>>(), c.Resolve<IEnumerable<string>>()));

      builder.RegisterType<UsesInt>().As<IGiveString>().Named<object>("My Name");
      builder.RegisterType<UsesString>().As<IGiveString>();

      builder.Register(c => "hello");
      builder.Register(c => 7);

      using (var container = builder.Build()) {

        var vm = new VisualizerViewModel(new TestContainerInfo(container));
        var window = new Window {
          Content = new VisualizerControl(vm) {
            HorizontalAlignment = HorizontalAlignment.Stretch,
            VerticalAlignment = VerticalAlignment.Stretch
          },
          Width = 600,
          Height = 600
        };
        window.ShowDialog();
        //AutofacVisualizer.VS2010.VisualizerDialog.TestShowVisualizer(container);
      }
    }
开发者ID:rjmurillo,项目名称:Autofac-Visualizer,代码行数:31,代码来源:Program.cs

示例10: WpfPropertyandCommand_Click

 private void WpfPropertyandCommand_Click(object sender, RoutedEventArgs e)
 {
     Window window = new Window { Content = new UsingWpfPropertyCommandView() };
     window.Height = 400;
     window.Width = 500;
     window.ShowDialog();
 }
开发者ID:SneshPrajapati,项目名称:ICommandDemo,代码行数:7,代码来源:MainWindow.xaml.cs

示例11: typeEditBtn_Click

        private void typeEditBtn_Click(object sender, RoutedEventArgs e)
        {
            Window w = new Window();
            w.Width = 500;
            w.Height = 200;

            // 우선 loader 말고 그냥 박음.. listVM class 에서 refresh해야하는데 복잡허네..

            //Excel_scheduleLoaderView e_slv = new Excel_scheduleLoaderView();

            //e_slv.Excel_underlyingCalcInfoViewModel_ = this.viewModel_.Excel_underlyingCalcInfoViewModel_;

            Excel_couponScheduleViewModel selectedVM = this.CouponScheduleDataGrid_.SelectedItem as Excel_couponScheduleViewModel;

            // 그냥 우선은 수정 불가로 해놓자으

            //e_slv.SelectedScheduleTypeViewModel_ = selectedVM;
            
            w.Content = selectedVM.loaderView();

            if (w.ShowDialog() == true)
            {
                //this.viewModel_.Excel_scheduleViewModel_[selectedIndex] = selectedVM;

                selectedVM.descriptionUpdate();

            }
            else
            {

            }
        }
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:32,代码来源:Excel_couponScheduleListView.xaml.cs

示例12: GetDuration

		public static Duration GetDuration(string fileName)
			{
			Duration naturalDuration = Duration.Automatic;
			Window w = new Window
				{
				Content = _videoElement = new MediaElement() { IsMuted = true },
				IsHitTestVisible = false,
				Width = 0,
				Height = 0,
				WindowStyle = WindowStyle.None,
				ShowInTaskbar = false,
				ShowActivated = false
				};
			_videoElement.MediaOpened += (sender, args) =>
				{
				naturalDuration = _videoElement.NaturalDuration;
				_videoElement.Close();
				w.Close();
				};
			_videoElement.LoadedBehavior = MediaState.Manual;
			_videoElement.UnloadedBehavior = MediaState.Manual;
			_videoElement.Source = new Uri(fileName);
			_videoElement.Play();
			w.ShowDialog();
			return naturalDuration;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:26,代码来源:MediaInfo.cs

示例13: EditAddressBook_Click

        private void EditAddressBook_Click(object sender, RoutedEventArgs e)
        {
            // Manually create window
            Window wnd = new Window();
            wnd.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            wnd.Owner = Application.Current.MainWindow;
            wnd.Title = Properties.Resources.AddressBookWindowTitle;
            wnd.Icon = BitmapFrame.Create(this.GetPackUri("Images/AddressBook_16.png"));
            wnd.Closing += (a, b) =>
            {
                var result = MessageBox.Show(Properties.Resources.AddressBookWindowLeaveConfirmation_MSG, Properties.Resources.AddressBookWindowLeaveConfirmation_CAP, MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                if (result == MessageBoxResult.Cancel)
                {
                    b.Cancel = true;
                    return;
                }

                wnd.DialogResult = (result == MessageBoxResult.Yes) ? true : false;
            };

            AddressBookEditorControl editorctrl = new AddressBookEditorControl();
            editorctrl.ValueWrapper = _valueRaw;
            wnd.Content = editorctrl;

            if (wnd.ShowDialog() == true)
            {
                _valueRaw = editorctrl.ValueWrapper;
            }
        }
开发者ID:pineiro,项目名称:AlarmWorkflow,代码行数:29,代码来源:AddressBookTypeEditorControl.xaml.cs

示例14: returnUnderlyingCalcSetBtn_Click

        private void returnUnderlyingCalcSetBtn_Click(object sender, RoutedEventArgs e)
        {
            Window w = new Window();
            w.Width = 500;
            w.Height = 200;

            Excel_underlyingCalcIDLoaderView e_ucIDlv = this.viewModel_.Excel_underlyingCalcIDViewModel_.loaderView();

            //e_ucIDlv.Excel_underlyingCalcInfoViewModel_ = this.viewModel_.Excel_underlyingCalcInfoViewModel_;

            //e_ucIDlv.SelectedUnderCalcIDTypeViewModel_ = this.viewModel_.Excel_underlyingCalcIDViewModel_.Clone();

            w.Content = e_ucIDlv;

            if (w.ShowDialog() == true)
            {

                this.viewModel_.Excel_underlyingCalcIDViewModel_
                    = e_ucIDlv.SelectedUnderCalcIDTypeViewModel_;

                this.viewModel_.Excel_underlyingCalcIDViewModel_.descriptionUpdate();

                this.returnUnderCalcDescriptionTxb_.Text = this.viewModel_.Excel_underlyingCalcIDViewModel_.Description_;
            }
            else
            {

            }

        }
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:30,代码来源:Excel_multiAsset_vanillaCallPutView.xaml.cs

示例15: button_Click

 private void button_Click(object sender, RoutedEventArgs e)
 {
     Button button = (Button)e.Source;
     if (button.Content.ToString() != "Close")
     {
         Type type = this.GetType();
         Assembly assembly = type.Assembly;
         object o = assembly.CreateInstance(type.Namespace + "." + button.Content);
         if (o is Window)
         {
             Window window = (Window)o;
             window.ShowDialog();
         }
         else if (o is Page)
         {
             Page p = (Page)o;
             Window w = new Window();
             w.Content = p;
             w.ShowDialog();
         }
     }
     else
     {
         this.Close();
     }
 }
开发者ID:cplotts,项目名称:WPFSLBlendModeFx,代码行数:26,代码来源:MainWindow.xaml.cs


注:本文中的System.Windows.Window.ShowDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。