This article describes a WPF application implementation that displays one or more lines of text notifications on the screen. It does not have a title bar and maximize the minimum button, you can have a translucent background to make the text display more clearly, mouse click after the prompts disappear.
1. Create a new WPF application.
2. Set the window's WindowStyle property to ' None ' to remove the title bar, set the AllowsTransparency property to ' true ' to allow transparency, and the topmost property to ' true ' to make the hint text appear at the top level. The Background property is set to #00000000 to make the window transparent.
3. Set the Background property of the grid. If you display a black text hint, you can use a semitransparent white background. A transparent effect, if produced by the Opacity property, makes the other elements within the container transparent. The simpler approach is to set the transparency by background the first two digits of the property.
4. Add the processing method to the MouseLeave, MouseDown, MouseEnter events for Windows. Adding MouseEnter and MouseLeave events is a way to deepen the background transparency when the mouse is drawn into the hint area, and to reduce the background transparency when the mouse draws the cue area. The MouseDown event's handling method causes the mouse to click the prompt area to cancel the prompt.
Copy Code code as follows:
Code
///<summary>
///Mouse Movement Method
///</summary>
///<param name= "Sender" ></param>
///<param name= "E" ></param>
private void Window_mouseenter (object sender, MouseEventArgs e)
{
Brush Brush = new SolidColorBrush (Color.FromArgb (0x78,0xff,0xff,0xff)); Create a solid color brush
grid. Background = brush; Applied to Grid
}
///<summary>
///Mouse Removal processing method
///</summary>
///<param name= "Sender" ></param>
///<param name= "E" ></param>
private void Window_mouseleave (object sender, MouseEventArgs e)
{
Brush Brush = new SolidColorBrush (Color.FromArgb (0x52, 0xFF, 0xFF, 0xFF)); Create a solid color brush
grid. Background = brush; Applied to Grid
}
///<summary>
///mouse Down processing method
///</summary>
///<param name= "Sender" ></param>
///<param name= "E" ></param>
private void Window_mousedown (object sender, MouseButtonEventArgs e)
{
Mainwindow.close (); or use Mainwindow.hide () to hide the window
}
This article applies to the. NET Framework 4