0% found this document useful (0 votes)
115 views

Transcript - Creating A Visual Basic WPF Application

This document provides instructions for creating a drawing application using WPF and Visual Basic. It describes how to create a new WPF project, set properties of the window and controls, add an InkCanvas control, edit the Xaml, add buttons, and add code to handle button clicks to clear drawings and close the application. The finished application allows the user to draw in an InkCanvas and includes Clear and Close buttons.

Uploaded by

fizo123
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views

Transcript - Creating A Visual Basic WPF Application

This document provides instructions for creating a drawing application using WPF and Visual Basic. It describes how to create a new WPF project, set properties of the window and controls, add an InkCanvas control, edit the Xaml, add buttons, and add code to handle button clicks to clear drawings and close the application. The finished application allows the user to draw in an InkCanvas and includes Clear and Close buttons.

Uploaded by

fizo123
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Video How to: Create a Drawing Application By Using WPF

Transcript I'm Kathleen McGrath, and in this presentation, you're going to learn how to create a WPF Application using Visual Basic Express. WPF stands for Windows Presentation Foundation, and its a new technology for creating rich, graphical applications. Like Windows Forms applications, WPF applications can be designed by dragging controls from the Toolbox to a design surface. In addition to having a designer, Properties window, and Toolbox, the IDE in WPF projects has a window that contains XAML. XAML is an acronym for Extensible Application Markup Language, which is used to create a user interface. In this demonstration, you will learn how to create a drawing application using WPF and Visual Basic.

Creating the Project


I'll create a new WPF application by clicking File, New Project, and then selecting WPF Application. I'll call this Ink Pad, and click OK. The WPF window you see in Designer view is a visual representation of the window that will open when your application is started. In Designer view, you can drag various controls from the Toolbox onto the design surface.

Setting Properties
I'm going to change the size of the WPF window by using the Properties window. If you do not see the Properties window, on the View menu, click Properties. This window lists the properties of the currently selected WPF window or control, and it's here that you can change the existing values. First I'll select the WPF window, then I'll change the size of the WPF Window by setting the Height property to 550 and the Width property to 370 in the Properties window, and then I'll change the Title to Ink Pad. Notice that the title changes in the title bar. Next, I'll change the Background property of the WPF window by clicking the drop-down control, and selecting a color.

The WPF window changes color. Now I'll add some controls to the form from the Toolbox. If the Toolbox isn't visible, you can open it by clicking the View menu, and then clicking Toolbox. I want to add an InkCanvas control, but I don't see it on the Toolbox. To add it, I'll rightclick the Toolbox, and then click Choose Items. In the WPF Components tab of the dialog box, I'll scroll down to InkCanvas, and select it. Then I'll click OK to add the InkCanvas control to the Toolbox. Now I'll drag the InkCanvas control from the Toolbox to the WPF window, and I'll set the following properties for the InkCanvas control in the Properties window. Property values for the InkCanvas control Property Width Height HorizontalAlignment VerticalAlignment Margin Value Auto Auto Stretch Stretch 9, 9, 9, 68

Editing XAML
If you look at the XAML window, you will see that these changes appear. You can also make these changes directly in the XAML markup. So next, I'll change the Background color of the InkCanvas control to yellow by adding the following attribute and value: Background="LightYellow". Next, Ill drag two buttons from the Toolbox to the bottom of the WPF window. Now I'll select Button1, and make some changes in the XAML markup. The text that appears on the button is located between the opening Button tag and the closing tag. I'll move my cursor between these two tags, and then type the word Clear. Now, I'll select Button2, and change the text to Close.

Adding the Code


Now I'll double-click Clear to create the event handler, and I'll add code that clears the drawing: Me.InkCanvas1.Strokes.Clear() I'll right-click and then click View Designer to change back to Design view, and then I'll double-click the Close button to create the event handler. Next, I'll add code that closes the application: Me.Close()

Running the Program


I'll press F5 to run the project, and when the application opens, I'll draw a picture in the InkCanvas control. If I make a mistake, I can click Clear to start over. Then I'll click Close to the close the application.

For More Information


You can get more information about developing Visual Basic applications in the Visual Basic Guided Tour. You can find other resources, such as technical articles and videos at the Beginner Developer Learning Center.

You might also like