public Form1() { InitializeComponent(); this.windowsXamlHost = new Microsoft.Toolkit.Forms.UI.XamlHost.WindowsXamlHost(); this.windowsXamlHost.InitialTypeName = "MyClassLibrary.WelcomePage"; this.windowsXamlHost.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowOnly; this.windowsXamlHost.Location = new System.Drawing.Point(0, 0); this.windowsXamlHost.Name = "windowsXamlHost"; this.windowsXamlHost.Size = new System.Drawing.Size(800, 800); this.windowsXamlHost.TabIndex = 0; this.windowsXamlHost.Text = "windowsXamlHost"; this.windowsXamlHost.Dock = System.Windows.Forms.DockStyle.Fill; //Adding the WindowsXamlHost to the Form this.Controls.Add(this.windowsXamlHost); //Setting the title of the Form this.Text = "WinForms .Net Core 3 and Xaml Islands"; this.ResumeLayout(false); //this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); //this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; //this.ClientSize = new System.Drawing.Size(800, 600); //this.Name = "Form1"; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.windowsXamlHost1 = new Microsoft.Toolkit.Forms.UI.XamlHost.WindowsXamlHost(); this.SuspendLayout(); // // windowsXamlHost1 // this.windowsXamlHost1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowOnly; this.windowsXamlHost1.InitialTypeName = null; this.windowsXamlHost1.Location = new System.Drawing.Point(0, 0); this.windowsXamlHost1.Name = "windowsXamlHost1"; this.windowsXamlHost1.Size = new System.Drawing.Size(800, 800); this.windowsXamlHost1.TabIndex = 0; this.windowsXamlHost1.Text = "windowsXamlHost1"; this.windowsXamlHost1.Dock = System.Windows.Forms.DockStyle.Fill; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 600); this.Controls.Add(this.windowsXamlHost1); this.Name = "Form1"; this.Text = "WinForms .Net Core 3 and Xaml Islands"; this.ResumeLayout(false); }
/// <summary> /// The XAML Islands methods to return a type of control. /// </summary> /// <param name="controlType"></param> /// <returns>The type of control to return.</returns> internal override Control GetControl(ControlEnum controlType) { var xamlControls = new ControlHelperXamlIslandControls(); var windowsXamlHost = new Microsoft.Toolkit.Forms.UI.XamlHost.WindowsXamlHost(); switch (controlType) { case ControlEnum.UWPTextbox: return(xamlControls.WrapInXamlHost(windowsXamlHost, xamlControls.GetTextBox())); case ControlEnum.UWPCheckbox: return(xamlControls.WrapInXamlHost(windowsXamlHost, xamlControls.GetCheckbox())); case ControlEnum.UWPRadioGroup: return(xamlControls.WrapInXamlHost(windowsXamlHost, xamlControls.GetRadio())); case ControlEnum.UWPCombobox: return(xamlControls.WrapInXamlHost(windowsXamlHost, xamlControls.GetCombobox())); case ControlEnum.UWPButton: return(xamlControls.WrapInXamlHost(windowsXamlHost, xamlControls.GetButton())); case ControlEnum.UWPSlider: return(xamlControls.WrapInXamlHost(windowsXamlHost, xamlControls.GetSlider())); case ControlEnum.UWPNotes: return(xamlControls.WrapInXamlHost(windowsXamlHost, xamlControls.GetNotes())); case ControlEnum.UWPCalendar: return(xamlControls.WrapInXamlHost(windowsXamlHost, xamlControls.GetCalendar())); case ControlEnum.UWPInk: return(xamlControls.GetInk()); case ControlEnum.UWPMap: return(xamlControls.GetMap()); case ControlEnum.UWPWebView: return(xamlControls.GetWebView()); case ControlEnum.UWPMediaPlayer: return(xamlControls.GetMedia()); default: return(null); } }
public CustomControlForm() { InitializeComponent(); var myHostControl = new Microsoft.Toolkit.Forms.UI.XamlHost.WindowsXamlHost(); myHostControl.Dock = DockStyle.Fill; myHostControl.Name = "uwpHost"; var customControl = new MyCustomControl(); customControl.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; customControl.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; myHostControl.Child = customControl; this.Controls.Add(myHostControl); }
public SimpleButtonForm() { InitializeComponent(); var myHostControl = new Microsoft.Toolkit.Forms.UI.XamlHost.WindowsXamlHost(); myHostControl.Dock = System.Windows.Forms.DockStyle.Fill; myHostControl.Name = "hostUwpButton"; var uwpButton = new Windows.UI.Xaml.Controls.Button(); uwpButton.Content = "Say Something!"; uwpButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; uwpButton.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; uwpButton.Click += UwpButton_Click; myHostControl.Child = uwpButton; this.Controls.Add(myHostControl); }
public Form1() { InitializeComponent(); SuspendLayout(); ClientSize = new System.Drawing.Size(1200, 768); Text = "Host Form"; ResumeLayout(true); var myHostControl = new Microsoft.Toolkit.Forms.UI.XamlHost.WindowsXamlHost(); var entryForm = Microsoft.Toolkit.Win32.UI.XamlHost.UWPTypeFactory.CreateXamlContentByType( "XamlIslandsSample.UwpApp.EntryForm") as UwpApp.EntryForm; myHostControl.Name = "myUwpAppHostControl"; myHostControl.Child = entryForm; myHostControl.Location = new System.Drawing.Point(0, 0); myHostControl.Size = Size; Controls.Add(myHostControl); }
public ThirdPartyControlWithStyleForm() { InitializeComponent(); var myHostControl = new Microsoft.Toolkit.Forms.UI.XamlHost.WindowsXamlHost(); myHostControl.Dock = DockStyle.Fill; myHostControl.Name = "uwpHost"; var customControl = new CustomCalendar(); customControl.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; customControl.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; myHostControl.Child = customControl; pnlXamlIsland.Controls.Add(myHostControl); var data = new DataModel(); customControl.DataContext = data; dtpPickDate.DataBindings.Add(new Binding(nameof(DateTimePicker.Value), data, nameof(DataModel.MyDate), true, DataSourceUpdateMode.OnPropertyChanged)); lblDate.DataBindings.Add(new Binding(nameof(Label.Text), data, nameof(DataModel.DateAsString), true, DataSourceUpdateMode.OnPropertyChanged)); }