Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use floating controls on WindowsFormsHost in WPF

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to use floating controls on WindowsFormsHost in WPF". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn how to use floating controls on WindowsFormsHost in WPF.

WindowsFormsHost is a control that hosts the windows form type in WPF. It has a high priority and can cover other types of controls on the same window. The secondary development control of TE is a WindowsFormsHost control.

In order to float the control on the WindowsFormsHost window and achieve the translucent effect, another window can pop up on the wpf window that hosts WindowsFormsHost, the size is the same as the lower window, and the position changes with the change of the lower window.

Specific implementation:

Suppose you have two windows for wpf: MainWindow and FloatWindow, where MainWindow is the window that hosts WindowsFormsHost and FloatWindow is the floating window above.

Initialize the floating window in the Loaded event of MainWindow, and change the size and position of the window. For more information, please see the following code:

_ 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

Above, you can keep the size and position of the floating window consistent with the lower window, and then set the transparency of the floating window.

You also need to set the following two properties of the main window in the Xaml of the floating window:

AllowsTransparency= "True" Background= "Transparent"

After that, the floating window above can add controls at will, set the Opacity property of the control, and then the control can be translucent.

Effect picture:

The above is all the content of this article entitled "how to use floating controls on WindowsFormsHost in WPF". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report