Wrong RootCompass indicators location

4 posts, 0 answers
  1. nagibator4000
    nagibator4000 avatar
    8 posts
    Member since:
    Feb 2017

    Posted 15 Sep 2017 Link to this post

    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.

  2. nagibator4000
    nagibator4000 avatar
    8 posts
    Member since:
    Feb 2017

    Posted 15 Sep 2017 Link to this post

    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
  3. Kalin
    Admin
    Kalin avatar
    1353 posts

    Posted 18 Sep 2017 Link to this post

    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.
  4. nagibator4000
    nagibator4000 avatar
    8 posts
    Member since:
    Feb 2017

    Posted 19 Sep 2017 Link to this post

    Hi, Kalin.

    Your solution is works. Thank you very much.

Back to Top