dialogresult

Where is Button.DialogResult in WPF?

寵の児 提交于 2020-01-10 17:29:27
问题 In System.Windows.Forms.Button there is a property DialogResult, where is this property in the System.Windows.Controls.Button (WPF)? 回答1: There is no built-in Button.DialogResult, but you can create your own (if you like) using a simple attached property: public class ButtonHelper { // Boilerplate code to register attached property "bool? DialogResult" public static bool? GetDialogResult(DependencyObject obj) { return (bool?)obj.GetValue(DialogResultProperty); } public static void

DialogResult problem in wpf

末鹿安然 提交于 2020-01-03 18:52:12
问题 I have a window that I open a few times as a ShowDialog. Every time I open it I use the new keyword in the first time i did: var myWindow = new MyWindow(); myWindow.ShowDialog(); second time I open it from the MyWindow View Model class: new MyWindow().ShowDialog(); in MyWindow code behind I have 2 events. one is when the user clcik ok and another when the user click cancel. void OnCancel(){ DialogResult = false; } void OnOk(){ DialogResult = true; } The events fires from the View Model class

DialogResult problem in wpf

蹲街弑〆低调 提交于 2020-01-03 18:51:54
问题 I have a window that I open a few times as a ShowDialog. Every time I open it I use the new keyword in the first time i did: var myWindow = new MyWindow(); myWindow.ShowDialog(); second time I open it from the MyWindow View Model class: new MyWindow().ShowDialog(); in MyWindow code behind I have 2 events. one is when the user clcik ok and another when the user click cancel. void OnCancel(){ DialogResult = false; } void OnOk(){ DialogResult = true; } The events fires from the View Model class

DialogResult.OK on SaveFileDialog not work

别等时光非礼了梦想. 提交于 2019-12-30 22:56:06
问题 I try, when I press save in SaveFileDialog I do something. I trying fix but always something wrong. SaveFileDialog dlg2 = new SaveFileDialog(); dlg2.Filter = "xml | *.xml"; dlg2.DefaultExt = "xml"; dlg2.ShowDialog(); if (dlg2.ShowDialog() == DialogResult.OK) {....} But I have error on OK - which say: Error: 'System.Nullable' does not contain a definition for 'OK' and no extension method 'OK' accepting a first argument of type 'System.Nullable' could be found (are you missing a using directive

Automatically clicking OK button in c# app

家住魔仙堡 提交于 2019-12-25 02:17:40
问题 Morning all, I have a c# app where if you press a start button a dialog box will open and the OK button will be automatically pressed. The problem is I don't know how to do this. The code is below: private void Start_Click(object sender, EventArgs e) { if (captureDevice.ShowDialog(this) == DialogResult.OK) { VideoCaptureDevice videoSource = captureDevice.VideoDevice; FinalVideo = captureDevice.VideoDevice; FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame); FinalVideo.Start(

How can I ensure closed dialogs are unregistered from INPC events?

ε祈祈猫儿з 提交于 2019-12-24 11:56:55
问题 I have an MVVM-Light based WPF application, with a dialog service (called WindowManager ) that opens up dialog windows bound to pre-initiated dialog view-models, like this: private enum ViewModelKind { PlanningGridVM, InputDialogVM, TreeViewDialogVM, SaveFileDialogVM, MessageBoxVM } /// <summary> /// Shows the Window linked to this ViewModel as a dialog window. /// </summary> /// <typeparam name="TViewModel">The type of the view model.</typeparam> /// <returns>Tri-state boolean dialog

MessageBox & Dialogs on XNA (C#)

若如初见. 提交于 2019-12-23 04:57:26
问题 I'm having the following code as part of my XNA game: private void gameOver() { if (!m_IsGameOver) { string message = String.Format("GAME OVER!!!{0}Your score is: {1}", Environment.NewLine, GameScore); if (MessageBox.Show(message, "GameOver", MessageBoxButtons.OK) == DialogResult.OK) { this.Exit(); } m_IsGameOver = true; } } private void gameWon() { string message = String.Format("You Won!!!{0}Your score is: {1}", Environment.NewLine, GameScore); if (MessageBox.Show(message, "You Won!",

Is it possible to overload the ShowDialog method for forms and return a different result?

删除回忆录丶 提交于 2019-12-21 07:42:24
问题 EDIT: This method actually works great and I asked it then found the solution later. I added the correct call in the overloaded ShowDialog() method (it's not exacly an overload, or even an override, but it works just the same. My new question is the one at the bottom. I have a form in which you click one of three buttons. I have defined an enum for the returned results. I want to make the call: MyFormResults res = MyForm.ShowDialog(); I can add a new ShowDialog method with this code: public

Using DialogResult Correctly

断了今生、忘了曾经 提交于 2019-12-17 07:30:14
问题 In an answer to a recent question I had (Here), Hans Passant stated that I should set the DialogResult to close my forms instead of form.Close() although I cannot seem to find out why? If I've read correctly, the MSDN documentation states that doing this will just hide the form instead of correctly disposing it which I believed .Close() to do? Extract from documentation. The Close method is not automatically called when the user clicks the Close button of a dialog box or sets the value of the

DialogResult can be set only after Window is created and shown as dialog

故事扮演 提交于 2019-12-10 16:26:56
问题 I have a main WPF window, mywindow.showDialog when a button is clicked on the window, a command is executed let's say the command is SendToTableCommand protected virtual void SendToTableExecute(object o) { UIThread.BeginInvoke(new Action<object>(SendToTableExecuteUI),o); } private void SendToTableExecuteUI(object o) { if (o is Control) { m_OwningWindow = UIHelper.FindVisualParent<Window>((Control)o); } do sth... if (m_OwningWindow != null) { //only set DialogResult when window is ShowDialog