New Posts New Posts RSS Feed: DialogManager closing problems
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

DialogManager closing problems

 Post Reply Post Reply
Author
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Topic: DialogManager closing problems
    Posted: 13-Jul-2012 at 12:51pm
It's done. I've pushed Cocktail 0.7.1 and the corresponding CocktailContrib 1.0.9 to NuGet.
Back to Top
JChris View Drop Down
Newbie
Newbie
Avatar

Joined: 13-Mar-2012
Location: Kansas
Posts: 8
Post Options Post Options   Quote JChris Quote  Post ReplyReply Direct Link To This Post Posted: 13-Jul-2012 at 7:06am
Thanks.   If you could, that would be really helpful.  We don't have a very good workaround.
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 12-Jul-2012 at 4:36pm
That is a bug. I've checked in a fix. Unfortunately, it just missed the 0.7 release I pushed out this morning. I can push out a 0.7.1 NuGet package with the fix if desired.
Back to Top
JChris View Drop Down
Newbie
Newbie
Avatar

Joined: 13-Mar-2012
Location: Kansas
Posts: 8
Post Options Post Options   Quote JChris Quote  Post ReplyReply Direct Link To This Post Posted: 12-Jul-2012 at 1:08pm
We have a situation where we:
yield return DialogManager.ShowDialogAsync(vm, new List<DialogResult>() { DialogResult.Cancel });
//Check vn properties and do more stuff...
When the DialogResult.OkCancel buttons are shown, and the Ok button clicked, all works as expected, however when we do not show the DialogResult.OkCancel button, but only the Cancel (as above), and then use our own button to handle Ok... as in:
this.DialogHost().TryClose(DialogResult.Ok);
the next iteration block never fires. It seems like TryClose of the DialogHost() does not honor the DialogResult passed to it.
Thanks for your help
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 26-Apr-2012 at 10:28am
I'm adding a TryClose method to the IDialogHost interface, so you'll be able to call this.DialogHost().TryClose(DialogResult.Ok).
 
I'm planning to officially release Cocktail v0.6 on May 2 together with DevForce 6.1.7. I believe we are still on track for the DF 6.1.7 release.
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 26-Apr-2012 at 9:58am
Here is what I tried from the child vm:

((Screen)(this.Parent)).TryClose();

The problem that I had is that the _dialogButton in the DialogHostBase is null so when it enters the canclose function it callsback with false: 

 public override void CanClose(Action<bool> callback)
        {
            try
            {
                if (_dialogButton != null)
                {
                    base.CanClose(callback);
                    return;
                }

                if (_cancelButton != null)
                {
                    DialogButton button = _dialogButtons.FirstOrDefault(b => b.Value.Equals(_cancelButton));
                    if (button == null || !button.Enabled)
                        return;
                    DialogResult = button.Value;
                    base.CanClose(callback);
                    return;
                }

                callback(false);
            }
            finally 
            {
                _dialogButton = null;
            }
        }

What I ended up doing was casting the parent as a DialogHostBase and then calling the Close function since the close function sets up the _dialogButton. Here is my new code in the child vm:
var parent = ((DialogHostBase)(this.Parent));
 
parent.Close(parent.DialogButtons.First());
Since I know that I only have one "OK" button I am just calling first(). It works great unless you can think of a way to make it easier.
-John Bloom
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 24-Apr-2012 at 2:09pm
Thanks. Looking back, that should have been obvious. Your help is much appreciated. 
-John Bloom
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 24-Apr-2012 at 2:04pm
Missed this post somehow. If your VM implements IChild, which it automatically does if you extend from Screen or Conductor, you have a Parent property. The parent in this case is the ChildWindow's VM. Just cast it to Screen and call TryClose on it.
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 24-Apr-2012 at 12:57pm
Bump :) We have a dialog that needs to be able to close the parent VM. It gives the user a list of options and as soon as they click an option it needs to close. Speed is the key for this dialog so we would like to avoid the user having to hit enter. Everything about the dialog works with the new stuff except we lost the ability to call TryClose() on the Manager's VM.
-John Bloom
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 19-Apr-2012 at 8:34am
We have a dialog that needs to close when the user clicks something other than the "Ok" or "Cancel" buttons. Calling TryClose() only closes the vm and not the childwindow.  Is there any way that the child window can close itself?
-John Bloom
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down