Using blend to Invoke Commands - Silverlight
In this article we will be seeing how we can use the Expression Blend SDK to invoke Commands in Silverlight.
Make sure that Blend 4 SDK is installed from the Microsoft Site here http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=3062
Lets create a new Silverlight Project SLSimpleCommands.
Lets add the following Dlls as references to the Silverlight project.
Create a ViewModel as shown below :
public class ViewModel
public ICommand PopupVM
return new InvokeChildCommand();
public class InvokeChildCommand : ICommand
public bool CanExecute(object parameter)
if (parameter != null)
CanExecuteChanged.Invoke(parameter, new EventArgs());
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
//Push the ViewModel into the Popup
Child child = new Child();
Add a new Child Window control to the project.
Lets move on to the MainPage.xaml.
Make sure you have added the namespaces as shown below :
Also important is how I have binded the ViewModel to the Grid.
Add the ViewModel as a Resource .
Bind the ViewModel to the Grid as shown below :
Now the ViewModel is available for any of the child controls of the Grid that want to use the the ViewModel.
Check out the use of InvokeCommandAction :
The Trigger is triggered when the Ellipse is loaded hence as soon as the page opens the Child window opens with it .
Lets give it a run .