This is a migrated thread and some comments may be shown as answers.
Wrong RootCompass indicators location
8 Answers 17 Views
This is a migrated thread and some comments may be shown as answers.
nagibator4000
Top achievements
Rank 1
nagibator4000 asked on 15 Sep 2017, 12:46 PM

Hello everyone.

I have shell WinForms application that hosts WPF User Control contains RadDocking. When I drag RadPane, a RootCompass indicators of RadDocking shows in wrong location (see attachment). It looks like indicators shows without offset of embedded WPF Control relatively shell WinForms application.

Is it bug? Or maybe is there a way to change a location of RootCompass indicators? 

 

Thank you.

8 Answers, 1 is accepted

Sort by
0
nagibator4000
Top achievements
Rank 1
answered on 15 Sep 2017, 01:51 PM

I've prepared a simple example reproduces that bug. You can find it using link below.

WinFormsWPF.sln is solution of WPF User Control contains RadDocking.

WFHost.sln is solution of WinForms host application.

https://drive.google.com/file/d/0B1j-40J5aVOfWFlYZVFtTnJidzg/view?usp=sharing
0
Kalin
Telerik team
answered on 18 Sep 2017, 04:11 PM
Hi Egor,

Please check the following example from our online XAML SDK repository that demonstrates how to host RadDocking in WinForms application:
https://github.com/telerik/xaml-sdk/tree/master/Docking/DockingInsideWinForms

What you need to do in your application is to add reference to Telerik.Windows.Controls.dll in the WFHost project in order to implement a custom IWindowInteropabilityAdapter as shown here. Afterwards set the adapter to the WPF control. You can find below all the needed code:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
 
    private void Form1_Load(object sender, EventArgs e)
    {
        var wpfControl = new WpfHosted.UserControl1();
        WindowInteropabilityHelper.SetWindowInteropabilityAdapter(wpfControl, new Adapter(this));
        elementHost1.Child = wpfControl;
    }
 
    private class Adapter : IWindowInteropabilityAdapter
    {
        private Form1 form;
        public Adapter(Form1 form)
        {
            this.form = form;
        }
 
        public int AbsoluteLeft
        {
            get { return this.form.PointToScreen(this.form.elementHost1.Location).X; }
        }
 
        public int AbsoluteTop
        {
            get { return this.form.PointToScreen(this.form.elementHost1.Location).Y; }
        }
 
        public IntPtr Handle
        {
            get { return this.form.Handle; }
        }
    }
}

Hope this helps.

Regards,
Kalin
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
nagibator4000
Top achievements
Rank 1
answered on 19 Sep 2017, 07:37 AM

Hi, Kalin.

Your solution is works. Thank you very much.

0
Shrikant
Top achievements
Rank 1
answered on 14 May 2020, 01:06 PM

Hi,

I checked the example and observed that the Root Compass Location is not at the center of the screen but a bit displaced.

 

I have attached the screen shot here.

 

 

0
Martin Ivanov
Telerik team
answered on 19 May 2020, 11:28 AM

Hello Egor,

I was able to reproduce this with a DPI scale set to 125%. Can you confirm that this is your setting too?

Regards,
Martin Ivanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Shrikant
Top achievements
Rank 1
answered on 19 May 2020, 12:18 PM

Hi Martin,

Yes, I reproduced it with DPI scale set to 125%. This is still reproducible when the DPI scale is set to 100% or 150%.

 

Thanks and regards,

Shrikant Mahapatra

 

 

0
Martin Ivanov
Telerik team
answered on 19 May 2020, 12:41 PM

Hello Shrikant,

I was able to reproduce this only on a DPI different than 100%. This happens because the PointToScreen method used in the Adapter class doesn't take into account the currently applied DPI. To resolve this, you can get the current DPI of the monitor and update the AbsoluteLeft and AbsoluteLeft property implementations of the Adapter class. For example:

public int AbsoluteLeft
{
	get 
	{
		Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
		var dx = graphics.DpiX / 96;
		graphics.Dispose();
		return (int)(this.form.PointToScreen(this.form.elementHost1.Location).X / dx);
	}
}

public int AbsoluteTop
{
	get 
	{
		Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
		var dy = graphics.DpiY / 96;
		graphics.Dispose();
		return (int)(this.form.PointToScreen(this.form.elementHost1.Location).Y / dy); 
	}
}

Regards,
Martin Ivanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Shrikant
Top achievements
Rank 1
answered on 06 Nov 2020, 05:11 AM

Hi Martin,

 

This solution works. Thanks.

Regards,

Shrikant

Asked by
nagibator4000
Top achievements
Rank 1
Answers by
nagibator4000
Top achievements
Rank 1
Kalin
Telerik team
Shrikant
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or