The WPF Settings Class Library project is a startup item, which sets the form to follow.

Source: Internet
Author: User

Original: WPF sets the class library project as a startup item and sets the form to follow.

1. To add the class Program.cs for startup, a static main function entry is required.

using System;using System.Windows;using System.Windows.Controls;

The brown part implements the position of the window fixed and follows.
public class Program {private static application _mainapplication; Internal static application MainApplication {get {return _mainapplication?? (_mainapplication = new Application ()); }} [STAThread] public static void Main (string[] args) {var mainwin = new Window ()            ; var Followwin = new Window ();//lambda expression mainwin.loaded + = (s, e) + = {Followwin.windo                    Wstartuplocation = windowstartuplocation.manual;                    Followwin.left = Mainwin.left + mainwin.width;                    Followwin.top = Mainwin.top;                Followwin.show (); };            //Occurs when the window position changes mainwin.locationchanged + = (s, e) + = {Fol                    Lowwin.left = Mainwin.left + mainwin.width;                Followwin.top = Mainwin.top; };Mainapplication.shutdownmode = Shutdownmode.onexplicitshutdown;        Mainapplication.run (Touch); }    }


2. Set the output type of the class library project to "Windows Application":


3. Set the Startup object to the program created in the first step

4, the operation can be.


The WPF Settings Class Library project is a startup item, which sets the form to follow.

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.