.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh

Home >> Articles >> Silverlight >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Using blend to Invoke Commands in Silverlight

Posted By:Mahadesh Mahalingappa       Posted Date: August 12, 2011    Points: 200    Category: Silverlight    URL: http://www.dotnetspark.com  

In this article we will be seeing how we can use the Expression Blend SDK to invoke Commands in Silverlight

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());
            return true;

        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 .

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend