Now Silverlight 4.0 Supports ICommand Interface but not fully only two controls
- Hyperlink button.
In Silverlight 4.0 the Button UI Element has to extra properties Command and CommandParamter.
Here i am going to show simple example using ICommand Interface in Silverlight 4.0.
First create a Silverlight application.
Now we need to Add Class file to the project and Implement the ICommand Interface.
Here the above code we are checking if user did not enter anything in textbox we are not executing the command . If He /She enters something and click button we will display the Entered Text in MessageBox.
Now lets Add XAML code to create Simple UI . Here i am adding one Textbox and Button.
Now lets do the Binding (wire up) our Command class to this UI. Here i am doing Element to Element data binding.
I do not have any code in CodeBehind in MainPage.Xmal.cs for the Button Click.
Now run the application and click Execute Command Button and see what is happening after that put some text in text box and click it now the message box displayed the text which you entered.