Add the PropertyGrid to the host, and the host to the WPF Grid : Forms « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="WpfApplication1.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Hosting a Windows Forms Property Grid in WPF"
  Loaded="Window_Loaded">
    <Grid Name="grid"/>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Shapes;

namespace WpfApplication1
{
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.Integration.WindowsFormsHost host =
                new System.Windows.Forms.Integration.WindowsFormsHost();
            System.Windows.Forms.PropertyGrid propertyGrid =
                new System.Windows.Forms.PropertyGrid();

            host.Child = propertyGrid;
            grid.Children.Add(host);
            
            
            propertyGrid.SelectedObject = this;
        }
    }
}
WPF Add The Property Grid To The Host And The Host To The W P F Grid








24.74.Forms
24.74.1.Display a notification icon in the system tray.Display a notification icon in the system tray.
24.74.2.Add the PropertyGrid to the host, and the host to the WPF GridAdd the PropertyGrid to the host, and the host to the WPF Grid
24.74.3.Use the IsSharedSizeScope attached property of the Grid elementUse the IsSharedSizeScope attached property of the Grid element
24.74.4.Control the Size of UI Elements in a FormControl the Size of UI Elements in a Form
24.74.5.Define the Tab Order of UI Elements in a FormDefine the Tab Order of UI Elements in a Form