WPF call Windows.Forms.PropertyGrid in xaml

1.Add reference System.Windows.Forms;

2.Add reference C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll

3.

<Window x:Class="WpfApp132.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:swf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        xmlns:local="clr-namespace:WpfApp132"
        WindowState="Maximized"
        Loaded="Window_Loaded"
        x:Name="rootWindow"
        mc:Ignorable="d"
        Title="MainWindow">
    <Grid>
        <WindowsFormsHost>
            <swf:PropertyGrid x:Name="propGrid"
                              SelectedObject="{x:Reference rootWindow}"/>
        </WindowsFormsHost>
    </Grid>
</Window>

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2025-01-01 20:30  FredGrit  阅读(7)  评论(0)    收藏  举报