WindowsFormsHost floating control methods in WPF

Source: Internet
Author: User

WindowsFormsHost is a control in WPF that hosts Windows Form types, and it has a particularly high priority and can be covered by other types of controls on the same window.

To be able to float the control on the WindowsFormsHost window and achieve a translucent effect, you can pop another window on the WPF window that hosts the WindowsFormsHost, which is the same size as the bottom window, and the position changes as the bottom window changes.

Specific implementation:

Suppose there are two windows: MainWindow and Floatwindow, where MainWindow is the window that hosts WindowsFormsHost, and Floatwindow is the window that floats above.

Initialize the floating window in the MainWindow loaded event, and make the window size and position change, see the code in detail.

_floatwin = new Floatwindow (this);

_floatwin.owner = this;

_floatwin.showintaskbar = false;

_floatwin.show ();

_floatwin.left = this. Left;

_floatwin.top = this. Top;

_floatwin.width = this. Width;

_floatwin.height = this. Height;

This allows the floating window and the bottom of the window to maintain the size and position of the same, and then set the transparent effect of the floating window, in the floating window of the XAML set the main window of the two properties, allowstransparency= "True" background= " Transparent "After the floating window can be arbitrarily added control, set the control's Opacity property, you can implement the control translucent.



This article is from the "Wclwksn_gis" blog, make sure to keep this source http://speciallst.blog.51cto.com/9749849/1834247

WindowsFormsHost floating control methods in WPF

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.