Passing ChildWindow as Command Parameter

Topics: Prism v2 - Silverlight 2, Prism v2 - Silverlight 3
Sep 7, 2009 at 10:49 AM

Hi,

I have a button inside a ChildWindow.

On button click I call a command (using prism feature) and I want to pass, as a command parameter, the childWindow.

How can I do?

Sep 7, 2009 at 2:34 PM

Hi

You can use Silverlight 3 element binding to accomplish this. Using the CAL default command with attached behavior for click, and assuming the ChildWindow is named dialog (x:Name="Dialog"), you could write XAML like this:

cal:Click.CommandParameter="{Binding ElementName=Dialog}"

I have created a small sample application that demonstrates this scenario working. It can be downloaded from here.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

 

Sep 7, 2009 at 3:10 PM
Edited Sep 8, 2009 at 8:19 AM

It works!

Thank you!

 

I have also another situation: I want pass the same childWindow as a command parameter; the problem is that I define in another page an array of these childWindow, each one with different parameters. Now, if I define the "name" or "x:name" property on the ChildWindow and then I recall this name in the {Binding ElementName=ChildWindowName}, Silverlight gives me an error "System.ArgumentException: Value does not fall within the expected range.", probably because I can have more than one ChildWindow with the same "name" or "x:name".

In this case, what can i do?

Thank you