在silverlight中通过对话框把选择的图片插入到RichTextBox中

主要是通过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);

 

 

posted on 2012-08-01 22:09  秋之白桦  阅读(639)  评论(0编辑  收藏  举报

导航