Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing ChildWindowResult back on close button pressed #91

Closed
JohnFredMeyer opened this issue Aug 15, 2019 · 1 comment · Fixed by #100
Closed

Passing ChildWindowResult back on close button pressed #91

JohnFredMeyer opened this issue Aug 15, 2019 · 1 comment · Fixed by #100
Milestone

Comments

@JohnFredMeyer
Copy link

JohnFredMeyer commented Aug 15, 2019

I may be wrong and please correct me if so. I am trying to pass a value back even if the user presses the close button. Here is code where that is occurring

image

It calls just this.Close();
I was thinking is there anyway we could make that public so it can be overridden? Or possibly having it Close with the ChildWindowResult as the parameter? If its never set it just passes null back? Or possible checks to see if ChildWindowResult is null and if so calls just Close() otherwise it calls Close(ChildWindowResult). I don't mind making changes if you approve or if there is a better way please let me know. Thanks again.

@JohnFredMeyer
Copy link
Author

JohnFredMeyer commented Aug 15, 2019

Ok figured out a way to do this. I am using ReactiveUI and Reactive extension but same can be done by intercepting on the closing event and using a bool within the view to determine if it is the first click of the closing button. If not I just return so it can close otherwise I cancel the close, set my bool, then close again. Still feels a little awkward. Let me know your thoughts?

public bool ClosingButtonClickProcessed { get; set; }

                Observable.FromEventPattern<CancelEventArgs>(this, nameof(this.Closing))
                    .Do(_ =>
                    {
                        if (ClosingButtonClickProcessed) return;

                        _.EventArgs.Cancel = true;
                        ClosingButtonClickProcessed = true;
                        this.Close(MyValueIWantToPassBack);
                    })
                    .Subscribe()
                    .DisposeWith(disposables);



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants