Print Page | Close Window

Dialog Buttons binding to method

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3623
Printed Date: 25-Mar-2025 at 5:13am


Topic: Dialog Buttons binding to method
Posted By: jlozina
Subject: Dialog Buttons binding to method
Date 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



Replies:
Posted By: mgood
Date 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
 


Posted By: mgood
Date 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".
 
http://drc.ideablade.com/xwiki/bin/view/Documentation/cocktail-dialog-manager#HAccessingthedialoghost - http://drc.ideablade.com/xwiki/bin/view/Documentation/cocktail-dialog-manager#HAccessingthedialoghost


Posted By: jlozina
Date 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;

}



Posted By: jlozina
Date Posted: 14-Sep-2012 at 3:55pm
I figured it out.



Print Page | Close Window