本文整理汇总了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();
}
}
}
示例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();
}
示例3: GenericShowDialog
private void GenericShowDialog(Window window)
{
this.Hide();
window.Owner = this;
window.ShowDialog();
this.Close();
}
示例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;
}
}
示例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);
}
}
示例6: DisplayClosingDialog
void DisplayClosingDialog(Window dlgWnd)
{
if (dlgWnd == null)
return;
CloseIfUnchanged();
dlgWnd.ShowDialog();
}
示例7: showWindow
public void showWindow(object viewModel)
{
var window = new Window();
window.Content = viewModel;
window.Owner = Application.Current.MainWindow;
window.ShowDialog();
}
示例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();
}
示例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);
}
}
示例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();
}
示例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
{
}
}
示例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;
}
示例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;
}
}
示例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();
}
}