DockPanel ImageOption.Image 未显示图像

DockPanel ImageOption.Image is not showing the image

我会长话短说,

我的问题是:我想在 DockPanel 中设置为图标的图像没有显示。

这是我的代码

DockPanel dock = new DockPanel();
dock.ImageOption.Image = <Bitmap image here>; //
dock.Controls.Add(UserControl1);
UserControl1.MyDockPanel = dock;

这里有专家意见吗?

谢谢

你可以像这样在cs中添加图片到DockPanel:

        DockPanel dock = new DockPanel();
        BitmapImage myBitmapImage = new BitmapImage();
        myBitmapImage.BeginInit();
        myBitmapImage.UriSource = new Uri("...\ico_48.ico", UriKind.RelativeOrAbsolute);
        myBitmapImage.DecodePixelWidth = 2048;
        myBitmapImage.EndInit();

        Image image = new Image();
        image.Source = myBitmapImage;
        dock.Children.Add(image);

        Content = dock;