In Visual Studio 2008
Open vs2008 and select "file", "new", and "project" in the main menu )...". Select "WPF Application (WPF Application)" as the project type )".
Name the project and select a folder path to store the project. Click "OK )".
Vs automatically adds some files to the project when creating the project. A window1.xaml file and an app. XAML file. Its structure is very similar to that of winform,The window1.designer. CS file is a code file and replacedThe XAML file of window1.xaml, such:
Open in the WPF DesignerWindow1.xaml
File, drag a button and text box in the toolbox.
Select the button to switch the attribute window to the event view (click a small yellow tab ). Double-click the "click" event and create a method called when the user clicks the button in the post code.
Note: If you cannot find the yellow button, it may be that Service Pack 1 for visualstudio is not installed on your computer. alternatively, you can double-click the button in the designer to achieve the same effect.
Vs automatically creates a method called when the user clicks the button in the post code:
Private void button#click (Object sender, routedeventargs e) {textbox1.text = "Hello WPF! ";}
The WPF Designer will also automatically specify a name for this text box"Textbox1
". Set the text box to "Hello WPF!" When the button is clicked! ", Press F5 on the keyboard to run the program:
Cool.
(Original)