gpt4 book ai didi

c# - 在 System.Windows.UIElement 中包装来自 System.Windows.Forms 的控件

转载 作者:太空宇宙 更新时间:2023-11-03 22:24:57 29 4
gpt4 key购买 nike

是否可以将旧的 System.Windows.Forms 控件包装在 System.Windows.UIElement 中?我知道 Browser Control以某种方式包装,基础来自 System.Windows.Forms。

如果这是可能的,实现会造成任何后果吗?

最佳答案

您可以在 WPF 窗体中承载 Windows 窗体控件。只需将它包装在 WindowsFormsHost 元素中。这显示了如何在 WPF 窗口中托管 Windows 窗体屏蔽测试框。

<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="HostingWfInWpf"
>

<Grid>

<WindowsFormsHost>
<wf:MaskedTextBox x:Name="mtbDate" Mask="00/00/0000"/>
</WindowsFormsHost>

</Grid>


</Window>

关于c# - 在 System.Windows.UIElement 中包装来自 System.Windows.Forms 的控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1754661/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com