我通过使用 Visual Studio 在 WPF 中编写了一个程序,我的程序运行良好。当我发布它时,它在 Internet Explorer 上看起来像下面的图像。我只想在顶部看到我的应用程序。
页面1.XML
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1">
<Grid>
<StackPanel Margin="0,0,0,0" Name="stackPanel"
HorizontalAlignment="Left" VerticalAlignment="Top" />
</Grid>
第1页.xaml.cs
using System.Windows.Controls;
using System.Windows.Forms.Integration;
using BenzinTakip;
namespace WPFHost
{
/// <summary>
/// Interaction logic for Page1.xaml
/// </summary>
public partial class Page1 : Page
{
private readonly Form1 mainForm = new Form1();
public Page1()
{
InitializeComponent();
//Create a Windows Forms Host to host a form
WindowsFormsHost windowsFormsHost = new WindowsFormsHost();
mainForm.TopLevel = false;
windowsFormsHost.Child = mainForm;
stackPanel.Children.Add(windowsFormsHost);
}
}
}
这是因为你的分辨率你必须改变你的表格的尺寸,它会适合。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句