本例实现的效果如下:

第一步:添加引用

using UserControl = System.Windows.Controls.UserControl;
 using System.Windows.Forms.Integration;//PaletteSet integration 
第二步

 
<UserControl x:Class="AcTools.UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:AcTools"
             mc:Ignorable="d" 
             MinWidth="100" MinHeight="600">
    <Grid>
        <ItemsControl ItemsSource="{Binding Dic}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Button Content="{Binding Path=Key}" Tag="{Binding Path=Value}"
                            Click="Button_Click"/>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Grid>
</UserControl>
 
代码:
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AcTools;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Colors;
using System.Runtime.CompilerServices;
using Wform = System.Windows.Forms;
using System.IO;
using System.Windows.Forms;
using Excel=  Microsoft.Office.Interop.Excel.Application;
using Autodesk.AutoCAD.Windows;
using UserControl = System.Windows.Controls.UserControl;
using System.Windows.Forms.Integration;
using Autodesk.AutoCAD.Internal;//PaletteSet integration
namespace AcTools
{
    public static class Class1
    {
        private static PaletteSet pset;
        [CommandMethod("xx")]
        public static void CaiYang()
        {   var db = Z.db;
            //var ed = Z.ed;
        
            if (pset is null)
            {
                pset = new PaletteSet("山水  QQ:443440204");
                var args = new Z.PsetArgs();
                args.Dic.Add("直线","line");
                args.Dic.Add("圆", "xx");
                args.Dic.Add("删除", "erase");
               
                var wpf = new UserControl1();
                wpf.DataContext = args;
                var host = new ElementHost()
                {
                    AutoSize = true,
                    Dock = DockStyle.Fill,
                    Child = wpf,
                };
                pset.Add("abc",host);
                pset.Visible = true;
                pset.Dock = DockSides.Left; 
                return;
            }
            pset.Visible = !pset.Visible;
        }
       
       
    }
}



















