Content for TaskDialog

Jun 5, 2008 at 7:37 PM
Edited Jun 5, 2008 at 10:22 PM
What I would like is to have a command link that has a textbox for a user input value (ie... What file name they would like to save it as). Is this possible to have user input in the TaskDialog?

Thanks,
Rod Yager
Coordinator
Jun 25, 2008 at 10:28 AM
Hi Rob,

Sorry it took so long to answer. I haven't been watching this space for a while, but I'm planning on a new release in the following month.

To answer your question: yes, it is quite possible. You can create a TaskDialog instance and add a CommandLink to the CommandLinks collection. You can put any content in the command link, including a text box (or assign it a content template). Then, when the dialog returns, you can inspect the value in the TaskDialogResult.Button property (which will give you the CommandLink instance).

I'm aware that this scenario is not perfect and I will be improving it in the upcoming version.

Aelij.
Jun 25, 2008 at 2:16 PM
Can you post an example? This is what I have but it doesn't work. The second command link is where I want to collect the user input value.

TaskDialog

 

td = new TaskDialog();

 

td.AllowDialogCancellation =

false;

 

td.Owner =

this;

 

td.Title =

"Save Customization";

 

td.Header =

"Save this screen customization as...";

 

td.MainIcon =

TaskDialogIconConverter.ConvertFrom(TaskDialogIcon.Question);

 

 

TaskDialogButtonData button = new TaskDialogButtonData(0, "Default", "Customization name will be " + CurrentScreenName);

 

td.CommandLinks.Add(button);

 

//button = new TaskDialogButtonData(1, "User Named", "Customization name will be " + CurrentScreenName + "_" + UserSession.PersonId);

 

 

Button btn = new Button();

 

 

StackPanel sp = new StackPanel();

 

 

TextBlock tbl = new TextBlock(new Run("Type new customization name"));

 

 

TextBox tb = new TextBox();

 

sp.Children.Add(tbl);

sp.Children.Add(tb);

btn.Content = sp;

td.CommandLinks.Add(btn);

td.Show();



aelij wrote:
Hi Rob,

Sorry it took so long to answer. I haven't been watching this space for a while, but I'm planning on a new release in the following month.

To answer your question: yes, it is quite possible. You can create a TaskDialog instance and add a CommandLink to the CommandLinks collection. You can put any content in the command link, including a text box (or assign it a content template). Then, when the dialog returns, you can inspect the value in the TaskDialogResult.Button property (which will give you the CommandLink instance).

I'm aware that this scenario is not perfect and I will be improving it in the upcoming version.

Aelij.



Jun 25, 2008 at 2:32 PM
Nevermind. I got it. Thanks!
Coordinator
Jun 25, 2008 at 2:42 PM
Instead of Button you should use the CommandLink class (which inherits from Button).
Jun 25, 2008 at 3:13 PM
Yep, got it. thanks.

Rod

aelij wrote:
Instead of Button you should use the CommandLink class (which inherits from Button).