dialogresult

Why does ShowDialog always return DialogResult.Cancel?

徘徊边缘 提交于 2019-12-10 13:39:04
问题 I have a custom made dialog winform. On it I have a label, textbox and 2 buttons (OK and Cancel). It also declares and defines overloaded execute methods for passing different parameter list. Dialog Winform is called as follows: var theDialog := new InputMsgBox; if theInputB.Execute('Awesome StackOverflow','Enter Text?',s,var s) = DialogResult.OK then begin Invalidate; SetText(s); end; Dialog Winform execute is defined as follow: method InputMsgBox.Execute(Title, theMessage, defaultanswer

Cannot use DialogResult

醉酒当歌 提交于 2019-12-08 16:10:22
问题 I tried to use DialogResult to check an Messagebox 's YesNoCancel . I'm using the following code which I don't see any problem with: DialogResult dlgResult = MessageBox.Show( "Save changes before closing?", "Warning", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); But Visual Studio throws me error saying 'System.Windows.Window.DialogResult' is a 'property' but is used like a 'type' 回答1: There is a confliction here between the DialogResult Enumeration and the Window.DialogResult

Can't set DialogResult in WPF

我只是一个虾纸丫 提交于 2019-12-05 08:41:22
问题 I show a WPF window using ShowDialog() from the calling window. The window opens and is modal as expected. However, in my OK and Cancel button's click events in the dialog window I set this.DialogResult = true (or false) respectively, and the value does not get set. The window closes as expected, but DialogResult is still null. Is this a bug in WPF? Or is there a reason the DialogResult property cannot be set yet does not throw an exception? The window is not hosted in a browser. Code in the

Caliburn Micro: DialogResult

谁说我不能喝 提交于 2019-12-04 13:34:45
问题 I can't find a solution for the following problem: I open a Dialog with the WindowManager from caliburn micro: public void UserNew() { this._windowManager.ShowDialog(new UserViewModel(this._windowManager)); } Now I need a DialogResult when the user close the dialog with the OK button. The ShowDialog method of WindowManager don't return a DialogResult... Can anyone help me? 回答1: I tend to use the View Model to handle determining what happened in the dialog. For instance, you can have an

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

只愿长相守 提交于 2019-12-04 01:51:29
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 new MyFormResults ShowDialog() { //Show modal dialog base.ShowDialog(); //This works and somehow I

Can't set DialogResult in WPF

杀马特。学长 韩版系。学妹 提交于 2019-12-03 22:08:34
I show a WPF window using ShowDialog() from the calling window. The window opens and is modal as expected. However, in my OK and Cancel button's click events in the dialog window I set this.DialogResult = true (or false) respectively, and the value does not get set. The window closes as expected, but DialogResult is still null. Is this a bug in WPF? Or is there a reason the DialogResult property cannot be set yet does not throw an exception? The window is not hosted in a browser. Code in the calling window: Window2 win = new Window2(); bool? result = win.ShowDialog(); if (result.HasValue &&

Caliburn Micro: DialogResult

女生的网名这么多〃 提交于 2019-12-03 08:36:31
I can't find a solution for the following problem: I open a Dialog with the WindowManager from caliburn micro: public void UserNew() { this._windowManager.ShowDialog(new UserViewModel(this._windowManager)); } Now I need a DialogResult when the user close the dialog with the OK button. The ShowDialog method of WindowManager don't return a DialogResult... Can anyone help me? I tend to use the View Model to handle determining what happened in the dialog. For instance, you can have an IsCancelled property on your UserViewModel that you can interrogate after returning from the ShowDialog call.

DialogResult in F#

痴心易碎 提交于 2019-12-02 10:41:22
问题 Trying to retrieve a DialogResult from a window in a MVVM app, I stumbled on this previous question. After implementing the suggested changes, the sample looks like: type DialogCloser() = static let DialogResultProperty = DependencyProperty.RegisterAttached("DialogResult", typeof<bool>, typeof<DialogCloser>, new PropertyMetadata(DialogResultChanged)) static member GetDialogResult (a:DependencyObject) = a.GetValue(DialogResultProperty) :?> bool static member SetDialogResult (a:DependencyObject

DialogResult in F#

僤鯓⒐⒋嵵緔 提交于 2019-12-02 03:18:07
Trying to retrieve a DialogResult from a window in a MVVM app, I stumbled on this previous question . After implementing the suggested changes, the sample looks like: type DialogCloser() = static let DialogResultProperty = DependencyProperty.RegisterAttached("DialogResult", typeof<bool>, typeof<DialogCloser>, new PropertyMetadata(DialogResultChanged)) static member GetDialogResult (a:DependencyObject) = a.GetValue(DialogResultProperty) :?> bool static member SetDialogResult (a:DependencyObject) (value:string) = a.SetValue(DialogResultProperty, value) member this.DialogResultChanged (a

Why is DialogResult a nullable bool in WPF?

痞子三分冷 提交于 2019-12-01 15:44:12
Can anyone think of a good explanation for the fact that result of a dialog is a nullable bool in WPF? This has always baffled me. In WinForms it was an enum type and that made a lot more sense to me. In my opinion this was done because in most cases you don't need the generalized specialized options like Retry or Ignore. If you need more than OK/Cancel, you are supposed to use some kind of task dialog, e.g. with written-out answers. That way, you're not limited to the few enum values someone thought of some decades ago, and the DialogResult is just positive/negative for basic use and you can