A set of .NET Framework managed libraries for developing graphical user interfaces.
Why does the resolution changes when calling WPF form from windows application form?
Hello All,
I have a windows form called Form1. There is a button1 on Form1, which opens another form PlotTool, which is a WPF form.
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var window = new System.Windows.Window();
var userControl = new PlotTool.UserControl1();
window.Content = userControl;
window.Show();
}
}
}
The WPF code is below
using System.Windows.Controls;
namespace PlotTool
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
}
//code
}
Clicking the button1 changes the resolution and size of the Windows Form1. It can be seen, as in attached picture, that the size of the windows Form1 decreases than original size and it also looks like its resolution has changed. I have tried controlling DPI on forms, but was not helpful.
Why is this happening and how can this be avoided? Hope you can help with this.
I am working in Visual Studio Community 2017 in Windows 10
I have .NET framework 4.6.1
Attached is image for reference.
Thank you.
Developer technologies | Windows Forms
Developer technologies | Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.