The first window class of the write WPF

Source: Internet
Author: User
/*
* User: Administrator
* Date: Time:
  */

UsingSystem;
UsingSystem. windows;
UsingSystem. Windows. input;

Namespace Wpftest
{
///   <Summary>
/// Description of cxywin.
///   </Summary>
Public   Class Cxywin: Window
{
Public Cxywin ()
{
Title = " Grow and shrink Test " ;
Windowstartuplocation = Windowstartuplocation. centerscreen;
Height = 400 ;
Width = 400 ;
This . Windowstyle = Windowstyle. threedborderwindow; // Display control buttons
// This. resizemode = resizemode. noresize; // Disable resize
This . Windowstate = Windowstate. maximized; // Window status
}

Protected   Override   Void Ontextinput (textcompositioneventargs E)
{
// The entered string is displayed on the title bar.
Base . Ontextinput (E );
If (E. Text = " \ B "   && Title. Length > 0 ) // Delete characters when character rollback
{
Title = Title. substring ( 0 , Title. Length - 1 );

}
Else   If ( ! Char . Iscontrol (E. Text [ 0 ])
{
Title = Title + E. Text;
}
}

Protected   Override   Void Onkeydown (keyeventargs E)
{
Base . Onkeydown (E );
// Adjust the position of the window to add moreCodeResize the form

If (E. Key = Key. UP)
{
Left -= Width * 0.05 ;
Top -= Height * 0.05 ;

}
If (E. Key = Key. down)
{
Left + = Width * 0.05 ;
Top + = Height * 0.05 ;
}

}

}
}

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.