MekasDotNet
Skip Navigation Links
Home
---------------
Code Converter
---------------
Downloads
---------------
Forums
---------------
ReferenceSites
-------------
Contact Us

Simple WPF Controls:

In this example we define  image, button and label controls and run the application to display them to the user.

1.  Open your Visual  C# Express/Professional Edition.Go to FileàNew Projectàselect WPF application and name it as SimpleWPF.



2.You see the following window1.xaml file that displays the default window1 and xaml code at the bottom of the screen.



3.To add an image to your project go to solution explorer right click on it Add Existing item-->Browse the required image and add it.



4.You type in the following xaml code in the window at the bottom.



5. In the code above is the application window and it is the root element. A window layout container can have only one child control, in this case it is the . The other types of layour containers available are ,,, and .Each of these layouts are discussed in other examples of WPF.

Grid is a flexible, all- purpose layour container. A grid organizes controls into a user-defined number of rows and columns by setting Grid,RowDefinitions and Grid.ColumnDefinitions. A Grid can accomodate multiple child controls. In our example above, we have taken a grid with default values of one row and one column.

6.The Image,Button and Label controls are incorporated in the Grid control.

7.Name property of Image gives the image its ID, and the Source property is used to select the image to be displayed.

8.In case of Button Control, the Content property is used to display the user defined text on the button. Same is the case with label.

9.The design window now appears as follows:



   
Your Feedback:
Post Name:
Post E-mail:  
Post Comment: