【发布时间】:2020-06-10 13:09:40
【问题描述】:
我想在顶部的 Winform 控件上显示 WPF 控件。 我希望 WPF 按钮出现在 Winform 文本框的顶部。
结果是WPF控件隐藏在winform TextBox后面看不到了。 这是为什么?
这是我的代码:
<UserControl x:Class="Philips.PmsCT.Host.Applications.ExamApplication.ScanRulerComponent.WPFHostWF"
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" Width="800" Height="120">
<Grid>
<WindowsFormsHost >
<wf:TextBox BackColor="LightBlue" />
</WindowsFormsHost>
<Button Width="100" Height="25" Background="Red"/>
</Grid>
【问题讨论】:
-
此代码在 WPF 控件中显示了一个 Windows 窗体,它与您的问题不匹配。父 Windows 窗体在哪里?
-
@ChrisF 我的猜测是,他想要文本框顶部的 WPF 按钮。所以要么他在使用 winforms 时遇到 wpf 问题,要么是一个简单的布局问题。
-
嗨 ChrisF,我会提出我的问题,我希望 WPF 按钮显示在 Winform 文本框的顶部。