اینم عکس از برنامه ساده !
111.jpg
اینم سورس نمونه
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Windows.Forms.Integration;
using System.Windows.Forms;
namespace WpfBrowserApplication1
{
/// <summary>
/// Interaction logic for Page1.xaml
/// </summary>
public partial class Page1 : Page
{
//private readonly MainForm mainForm = new MainForm();//این شی از فایل WinFormProject ایجاد شده است
//private readonly ESECo_Manager.frmLogin MainForm = new ESECo_Manager.frmLogin();
private readonly WindowsFormsApplication1.Form1 frm = new WindowsFormsApplication1.Form1();
public Page1()
{
InitializeComponent();
//Create a Windows Forms Host to host a form
WindowsFormsHost windowsFormsHost = new WindowsFormsHost();
stackPanel.Width = frm.Width;
stackPanel.Height = frm.Height;
windowsFormsHost.Width = frm.Width;
windowsFormsHost.Height = frm.Height;
frm.TopLevel = false;
windowsFormsHost.Child = frm;
stackPanel.Children.Add(windowsFormsHost);
}
}
}
این هم قسمت XAML
<Page x:Class="WpfBrowserApplication1.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="Page1">
<Grid>
<StackPanel Margin="0,0,0,0" Name="stackPanel"
HorizontalAlignment="Left" VerticalAlignment="Top" />
</Grid>
</Page>