Silverlight Application; How can I add code to a buttons event handler?
I'm following this tutorial (beginner Hello World Silverlight Application)
In this step it shows how to add code to the event handl开发者_StackOverflow社区er of a button,
this is done in a xaml.cs file but i cant find it anywhere, can anybody tell me where I can add code to the event handler of my button in Visual Studio 2010
Firstly, it seems the name of the control created automatically with a new Silverlight project has changed since Silverlight 2 (as in the tutorial you're following). A new Silverlight 4 project has MainPage.xaml (and MainPage.xaml.cs) instead of Page.xaml and Page.xaml.cs.
To access MainPage.xaml.cs (which is where you'd put the event handler), expand the MainPage.xaml node in Solution Explorer. This should should show MainPage.xaml.cs under MainPage.xaml. Alternatively, right-click Click="MyButton_Click"
in MainPage.xaml and choose 'Navigate to Event Handler'.
精彩评论