This article describes the method of popping up custom windows in WPF. Share it for your reference, as follows:
Test environment:
[1]VS2010SP1
[2]WPF (.NET Framework 4) project
Content introduction
How to pop up custom windows in WPF project
Step 1: Customize the window
Add a new Window item to the current project. The code for the XAML part is omitted. The following is the code for the C# part.
namespace { /// <summary> /// Interaction logic for /// </summary> public partial class InputStringWindow : Window { public InputStringWindow() { InitializeComponent(); //Set the default input focus (this,tbContent); } private void button1_Click(object sender, RoutedEventArgs e) { = (); if ( > 0) { Close();//Close the window } else { ("The input string length cannot be empty!"); } } } }
Step 2: Pop up the window you just defined
InputStringWindow isw = new InputStringWindow(); = "Name a new page"; ();//Mode, pop up!//()//No mode, pop up!
For more information about C# related content, please check out the topic of this site:Summary of C# form operation skills》、《Tutorial on the usage of common C# controls》、《Summary of WinForm control usage》、《Summary of thread usage techniques for C# programming》、《Summary of C# operation skills》、《Summary of XML file operation skills in C#》、《C# data structure and algorithm tutorial》、《Summary of C# array operation skills"and"Introduction to C# object-oriented programming tutorial》
I hope this article will be helpful to everyone's C# programming.