New Posts New Posts RSS Feed: Dialog Buttons binding to method
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Dialog Buttons binding to method

 Post Reply Post Reply
Author
jlozina View Drop Down
Newbie
Newbie


Joined: 20-Jul-2011
Posts: 9
Post Options Post Options   Quote jlozina Quote  Post ReplyReply Direct Link To This Post Topic: Dialog Buttons binding to method
    Posted: 12-Sep-2012 at 5:30am
Hi
 
I'm trying to bind the buttons in the Dialog to a method but it seems always to go to  CanClose(Action<bool> callback) Method.
 
If  I call the Dialog with the following buttons yield return _dialogManager.ShowDialogAsync(addressEditor, new[] { "Previous", "Next", "Cancel" }); how do I get the buttons to call a  void Previous() or void Next() method in the Dialog VM?
 
Regards,
Joe
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-Sep-2012 at 7:19am
You can't do that with the DialogManager as-is. The buttons are designed to close the dialog with a certain DialogResult, not to trigger other actions in the dialog. If you want to build a wizard, you have two options:
1. Make Previous/Cancel part of addressEditor
2. Don't use the DialogManager and build the wizard yourself from scratch
 
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-Sep-2012 at 10:27am
BTW, you can pass an empty list of buttons to the DialogManager and  do all the buttons yourself in addressEditor, including the Cancel button.
 
You can then access the DialogHost from addressEditor as described in the following link and call IDialogHost.TryClose to close the dialog if the user clicks Cancel or "Finish".
 
Back to Top
jlozina View Drop Down
Newbie
Newbie


Joined: 20-Jul-2011
Posts: 9
Post Options Post Options   Quote jlozina Quote  Post ReplyReply Direct Link To This Post Posted: 14-Sep-2012 at 4:26am
Thanks for that.
 
If I pass an empty list of buttons to the DialogManager how would I simulate the Ok button behavior.
 
So in the parent VM I can access the properties of Dialog when I finish with it.
 

public IEnumerable<IResult> EditAddress(){

var addressEditor = _addressEditorFactory.CreatePart();

yield return _dialogManager.ShowDialogAsync(addressEditor, new List<DialogResult>() );

string test = addressEditor.MiddleName;

}

Back to Top
jlozina View Drop Down
Newbie
Newbie


Joined: 20-Jul-2011
Posts: 9
Post Options Post Options   Quote jlozina Quote  Post ReplyReply Direct Link To This Post Posted: 14-Sep-2012 at 3:55pm
I figured it out.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down