Print Page | Close Window

DialogHost custom labels

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=4149
Printed Date: 19-Sep-2025 at 10:01pm


Topic: DialogHost custom labels
Posted By: murray.bryant
Subject: DialogHost custom labels
Date Posted: 15-May-2013 at 1:33am
Hi

I am in need of some custom labels in my dialog ( Pass,Fail,Cancel)

And I know I can achieve that with the following

var result = await _dialogManager.ShowDialogAsync(mod, new[] {"Pass", "Fail", "Cancel"});

where mod is my custom view model.

What I can't work out how to do is to be able to enable/disable the buttons within the view model.

Is this the best way to do this or is there another way?

When I tried using custom commands

 var commands = new List<IDialogUICommand<DialogResult>>();
            _passCommand = new DialogUICommand<DialogResult>("Pass", DialogResult.Ok, true, false);
            commands.Add(_passCommand);
            _failCommand = new DialogUICommand<DialogResult>("Fail", DialogResult.No, false, false);
            commands.Add(_failCommand);
            var closeCommand = new DialogUICommand<DialogResult>("Cancel", DialogResult.Cancel, false, true);
            commands.Add(closeCommand);
var result = await _dialogManager.ShowDialogAsync(mod, commands);


the labels did not show correctly on the buttons. Is this the better way, and if so what have I done wrong with the labels

thanks

Murray




Replies:
Posted By: mgood
Date Posted: 15-May-2013 at 6:13am
Yes, using commands is the way to go if you want control over the labels and state of the commands. Your issue is that you are calling the wrong ShowDialogAsync method. You need to swap commands and mod. The first parameter is the list of commands, followed by the view model.

http://cocktail.ideablade.com/CocktailHelpReference/net45/Cocktail~Cocktail.IDialogManager~ShowDialogAsync%60%601%28IEnumerable%7BIDialogUICommand%7B%60%600%7D%7D,Object,String%29.html - http://cocktail.ideablade.com/CocktailHelpReference/net45/Cocktail~Cocktail.IDialogManager~ShowDialogAsync%60%601(IEnumerable%7BIDialogUICommand%7B%60%600%7D%7D,Object,String).html



Print Page | Close Window