如何在WPF中的文本框中设置图像 [英] how to set image in textbox in wpf
本文介绍了如何在WPF中的文本框中设置图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序中有文本框,有时我想向其中添加图像
像Microsoft Office Word一样,我将同时具有文本和图像
有可能吗?
如果有可能怎么办?
谢谢.
I Have TextBox In My Application That I Want to Add Image To This , Some Times
Like Microsoft Office Word I am Going To Have Both Text And Image
Is it Possible ?
If It possible How?
Thanks.
推荐答案
改为使用RichTextBox控件.检查此 http://msdn.microsoft.com/en -us/library/ee681613%28v = vs.95%29.aspx#inline_images_or_other_elements [
Use a RichTextBox control instead. Check this out http://msdn.microsoft.com/en-us/library/ee681613%28v=vs.95%29.aspx#inline_images_or_other_elements[^]
ok so I just noticed the first link I added was for silverlight? I was tired sorry.
So I thought I would add some example code
BitmapImage bitmap = new BitmapImage(new Uri(@"testImg.png", UriKind.RelativeOrAbsolute));
Image image = new Image();
image.Source = bitmap;
image.Width = 32;
image.Height = 32;
InlineUIContainer container = new InlineUIContainer(image);
Paragraph paragraph = new Paragraph(container);
paragraph.Inlines.Add("This is a image and some text!");
richTextBox1.Document.Blocks.Add(paragraph);
这篇关于如何在WPF中的文本框中设置图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文