UserControl


< UserControl x:Class="Namespace.Forms.MyForm_View" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
   MinHeight=
   MinWidth=
   Height=
   Width=
>


Add a "User Control (WPF)"
Add a reference System.Xaml
Remove the ".Forms" entry in the namepsace


copy the height and width from the usercontrol


Forms.FormatTable_Model oModel = new Forms.FormatTable_Model(); 

General.g_oThread = new System.Threading.Thread(delegate ()
{
    System.Windows.Controls.UserControl myusercontrol;
    myusercontrol = new Forms.FormatTable_View();

    Forms.FormatTable_View oView2 = (Forms.FormatTable_View)myusercontrol;
    Forms.FormatTable_Presenter oPresenter = new Forms.FormatTable_Presenter(oModel, oView2);

    General.g_oMyWindow = new System.Windows.Window()
    {
        Title = Constants.MESSAGE_CAPTION + "Format Table",
        Content = myusercontrol,
        ShowInTaskbar = false,
        ResizeMode = System.Windows.ResizeMode.NoResize,
        Height = myusercontrol.Height + 30,
        Width = myusercontrol.Width + 6
    };

    //positioning in the center
    General.g_oInteropHelper = new System.Windows.Interop.WindowInteropHelper(General.g_oMyWindow);
    General.g_oInteropHelper.Owner = (System.IntPtr)General.g_oExcel.Application.Hwnd;

    Constants.Structure_RECT oRect;
    General.GetWindowRect((System.IntPtr)General.g_oExcel.Application.Hwnd, out oRect);
    int nonWPFOwnerLeft = oRect.Left;
    int nonWPFOwnerWidth = oRect.Right - oRect.Left;
    int nonWPFOwnerTop = oRect.Top;
    int nonWPFOwnerHeight = oRect.Bottom - oRect.Top;

    General.g_oMyWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
    General.g_oMyWindow.Left = nonWPFOwnerLeft + (nonWPFOwnerWidth - General.g_oMyWindow.Width) / 2;
    General.g_oMyWindow.Top = nonWPFOwnerTop + (nonWPFOwnerHeight - General.g_oMyWindow.Height) / 2;

    General.g_oMyWindow.ShowDialog();

    System.Windows.Threading.Dispatcher.Run();
});

General.g_oThread.SetApartmentState(System.Threading.ApartmentState.STA);
General.g_oThread.Start();




© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Top

PrevNext