WPF背景图片 [英] WPF Background Image

查看:233
本文介绍了WPF背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好



如果不使用明确的语言很难写这个但我会尝试。

我有一个WPG库,一个WFP用户控件,现在我想做的就是将一个scrollviewer的背景设置为一个图像并平铺它



听起来很简单不是吗?



当我尝试在设计器中设置它时(如选择我的.bmp图像通过MS绘制保存)它永远不会显示(它没有巧妙地将它添加到资源中文件(就像我习惯使用Winforms一样)没有它在标记中输入一个URL(XAML< - 总是很有趣,从微软那里听Jessie Liberty说吧)



Hi Guys

Very difficult to write this without using explicit language but i will try.
I have a WPG library, with a WFP user control in it, now all I want to do is set the background of a scrollviewer to an image and tile it

Sounds very simple doesnt it ?

When I try and set it in the designer (as in select my .bmp image saved via MS paint) it never shows up ( it does not neatly add it to a resource file (Like I am so used to with Winforms) no it inputs a url in the markup (XAML <- Always fun listening to Jessie Liberty from microsoft say it)

<ScrollViewer.Background>
               <ImageBrush ImageSource="Images/diagramBG1.bmp" />
           </ScrollViewer.Background>





因此,当我运行它时,我得到以下



''为'System.Windows.Baml2006提供价值.TypeConverterMarkupExtension''引发异常。''行号''12''和行位置''18''。



我是的将图像复制到本地路径和目录



所以我真正想做的是! :

能够通过代码和64位字符串或图像的字节数组分配图像



感觉就像一个总菜鸟,问一些概念上非常简单的东西(对于其他所有东西)但是对于WPF。



先谢谢你



So when i run it I get the following

''Provide value on ''System.Windows.Baml2006.TypeConverterMarkupExtension'' threw an exception.'' Line number ''12'' and line position ''18''.

And yes I did copy the image to the local path and directory

So What i would really like to do is! :
be able to assign the image via code and a 64 bit string or a byte array of the image

Feel like a total noob by asking somethign that is conceptually very easy (for just about everything else) but for WPF.

Thanks in Advance

推荐答案

我的第一个问题是:你是否在项目资源管理器中将bacground图像的编译模式设置为资源?



如果是,那么WPF可能不喜欢bmp图像。我总是使用png格式。占用更少的空间而且它是无损的。
My first question is: Have you set the bacground image''s compile mode to resource in the project explorer?

If yes, then maybe WPF doesn''t like bmp images. I allways use png format. Takes less space and it''s lossless.


这篇关于WPF背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆