我们可以使用编辑模板来定义RichTextBox的背景图片
下面是实现步骤:
1. 创建Silverlight项目,命名为RichTextBoxBackground
<a href="http://blog.51cto.com/attachment/201105/204254194.png" target="_blank"></a>
2. 右击项目,添加现有项目,选择要添加的背景图片,这里我们添加一个256*256的图片
<a href="http://blog.51cto.com/attachment/201105/204323888.png" target="_blank"></a>
3. 向美化板中添加RichTextBox
4. 设置其长宽均为256*256
<a href="http://blog.51cto.com/attachment/201105/204448791.png" target="_blank"></a>
5. 右击RichTextBox,选择编辑模板,编辑拷贝
<a href="http://blog.51cto.com/attachment/201105/204510280.png" target="_blank"></a>
6. 选择Border,将其背景色重置
<a href="http://blog.51cto.com/attachment/201105/204547715.png" target="_blank"></a>
7. 导航到Title Brush,选择添加的图片
8. 运行后效果图下:
<a href="http://blog.51cto.com/attachment/201105/204703211.png" target="_blank"></a>
本文转自xshf12345 51CTO博客,原文链接:http://blog.51cto.com/alexis/574836,如需转载请自行联系原作者