Microsoft enterprise database 5.0 study notes (8) Windows Forms and WPF applications

Source: Internet
Author: User

Although they are different technologies, they share the same basic features. In particular, they all use form objects to implement user interfaces and allow you to specify the code that runs when the application starts. By default, the startup Code only loads and displays the main form, but you can modify it to create a unified container, assemble it with the Enterprise Library Information, and process the objects used in the application. For example, to reduce the startup time and memory usage, you may not want to create all forms at startup. You can store a container object to process the form and other required objects.

WindowsForm application

The following shows howWindowsCreate and assemble the Enterprise Library container in the form

Static void main () <br/>{< br/> var Container = new unitycontainer () <br/>. addnewextension <enterpriselibrarycoreextension> (); <br/> application. run (container. resolve <form1> (); <br/>}< br/>

 

WPFApplications

WPFThe application uses the startup code to load and display the main form.

When creating a WPF project, Visual Studio creates an application definition file. If C # is used, it is named app. XAML and has an associated code file app. XAML. CS.

XML file content

<Application X: class = "window1" <br/> xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" <br/> xmlns: X = "http://schemas.microsoft.com/winfx/2006/xaml" <br/> startup = "createcontainer"> <br/> <application. resources> </P> <p> </application. resources> <br/> </Application> <br/>

 

CSFile Content

Private void createcontainer (Object sender, startupeventargs e) <br/>{< br/> var Container = new unitycontainer () <br/>. addnewextension <enterpriselibrarycoreextension> (); <br/> window1 thewindow = container. resolve <window1> (); <br/> thewindow. show (); <br/>}< br/>

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.