询问者
c#中如何把现成的image变成背景图呢

问题
全部回复
-
Hi,
请问你的项目是什么类型的? winform或者wpf?
如果是Winform的话设置背景图片或者如2楼说的那样操作应该是可行的。 如果是wpf的话,你可以参考下面的方法:
方法一:
xaml中: <控件> <控件.Background> <ImageBrush ImageSource="/WpfApplication1;component/Images/xxx.jpg"/> </控件.Background> </控件>
方法二:
xxxx.cs中: ImageBrush b3 = new ImageBrush(); b3.ImageSource = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute)); this.Background = b3;
Regards,
Moonlight
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
Hi,
>>这样不行哦,我是自定义了一个image类,里面做了很多定点缩放,如果不使用这个类的话,就不能达到缩放目的
这个类有继承Image对象吗? 如果继承了,你直接用自定义的类接受图像并赋值给背景。
Regards,
Moonlight
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
- 已编辑 Moonlight ShengMicrosoft contingent staff 2016年6月8日 7:14