UserControl


Add a WPF User Control


namespace WPF 
{
   public partial class MyWPF : System.Windows.Controls.UserControl
   {
      public MyWPF()
      {
         InitializeComponent()
      }
   }
}

Displays a WPF

System.IntPtr ohandle; 
DataManagerProject.Structure_RECT oRect = new Structure_RECT();
System.Windows.Forms.NativeWindow nativeWindow;
ohandle = Method_HandleGet(Globals.ThisAddIn.Application);
nativeWindow = new System.Windows.Forms.NativeWindow();
nativeWindow.AssignHandle(ohandle);
Constants.GetWindowRect(ohandle, ref oRect);

System.Windows.Controls.UserControl myusercontrol;
myusercontrol = new WPF.MyWPF();

System.Windows.Window mywindow = new System.Windows.Window
{
    WindowStyle = System.Windows.WindowStyle.ToolWindow,
    Title = Constants.MESSAGE_CAPTION + "Title",
    Content = myusercontrol,
    ResizeMode = System.Windows.ResizeMode.CanResize,
};

mywindow.Height = 600;
mywindow.Width = 600;

int Center_x;
int Center_y;
Center_x = oRect.Left + (oRect.Right - oRect.Left) / 2;
Center_y = oRect.Top + (oRect.Bottom - oRect.Top) / 2;

int windowCenter_x;
int windowCenter_y;
windowCenter_x = Center_x - (int)mywindow.Height / 2;
windowCenter_y = Center_y - (int)mywindow.Width / 2;

mywindow.Left = windowCenter_x; // * 72 / 96;
mywindow.Top = windowCenter_y; // * 72 / 96;

mywindow.MinHeight = mywindow.Height;
mywindow.MinWidth = mywindow.Width;

mywindow.ShowDialog();

nativeWindow.ReleaseHandle();


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext