主要是通过OpenFileDialog打开一个对话框,然后把选择的图片插入到RichTextBox中,具体代码如下

OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Image Files (*.bmp, *.jpg)|*.bmp;*.jpg ";
            bool? result = open.ShowDialog();
            if (result != null && result == true)
            {
                Image image = new Image();
                BitmapImage bimage = new BitmapImage();
                bimage.SetSource(open.File.OpenRead());
                image.Source = bimage;
                image.Width = 50;
                image.Height = 50;

                InlineUIContainer container = new InlineUIContainer();
                container.Child = image;
                TestRTB.Selection.Insert(container);

 

 

相关文章: