Weekend charge of WPF (Iv.). Working between multiple windows

Source: Internet
Author: User

Multi-window instance:

1. How to customize the window program you want to start in the case of multiple Windows

1<application x:class="toolbar. APP"2xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"3xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"4Startupuri="MainWindow.xaml">5<Application.Resources>6          7</Application.Resources>8</Application>
App.xaml

You can Modify the name of the window you want to launch by startupuri= "MainWindow.xaml"

2. Fixed window size, no modification

Resizemode= "Noresize"

3. Where the dialog box pops up on the screen

windowstartuplocation= "Centerscreen"

4. Modify window name

Title= "About"

5. Maximize Window

Windowstate= "Maximized"

6. To pass a value to a dialog box

The window is actually a class

 Public Partial class Aboutwindow:window

So that we can define a public property in the class to receive the value, before the new instance

Pass the value to the attribute in this class, and finally the load event in the child window to accept

 Public Partial class Aboutwindow:window    {        publicstringgetset;}          Public string Get Set ; } ...

Main Window

usingSystem.Windows.Input;usingSystem.Windows.Media;usingSystem.Windows.Media.Imaging;usingSystem.Windows.Navigation;usingSystem.Windows.Shapes;namespacetoolbar{/// <summary>    ///the interactive logic of MainWindow.xaml/// </summary>     Public Partial classMainwindow:window { PublicMainWindow () {InitializeComponent (); }        Private voidButton_click_1 (Objectsender, RoutedEventArgs e) {            stringt =TX.            Text; Aboutwindow Aboutwin=NewAboutwindow (); Aboutwin.username=T;            Aboutwin.showdialog ();                    MessageBox.Show (ABOUTWIN.PWD); }    }}

child window

Private void Window_loaded_1 (object  sender, RoutedEventArgs e)        {            = UserName;        }

7. child window return Properties

Whether the child window is passed to the main window or the master . To . The sub-values are passed through the property

8.OpenFileDialog

  Public Partial classMainwindow:window { PublicMainWindow () {InitializeComponent (); }        Private voidButton_click_1 (Objectsender, RoutedEventArgs e) {OpenFileDialog file=NewOpenFileDialog (); //file FilterFile. Filter ="text Files |*.txt| PNG image |*.png| Video |*.avi"; File.        ShowDialog (); }    }

Weekend charge of WPF (Iv.). Working between multiple windows

Related Article

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.