在VS2008中使用wpf的透明png

时间:2009-10-22 16:28:01

标签: wpf transactions png

我想在WPF VS2008中创建一个半透明的UI,所以我使我的表单透明,我想在它上面显示一个半透明的png(包括“hole”)。 如何显示半透明png?

半透明,意味着它有你可以看到的洞。

另外,如何在不使用WPF的情况下在C#中完成此操作。

感谢。

1 个答案:

答案 0 :(得分:4)

你应该只需要使用Image控件,WPF应该处理剩下的事情:

<Image Source="myimage.png" />

或者在纯C#中:

BitmapImage sourceImage = new BitmapImage();
sourceImage.BeginInit();
sourceImage.UriSource = new Uri("myimage.png", UriKind.RelativeOrAbsolute);
sourceImage.EndInit();

Image myImage = new Image();
myImage.Source = sourceImage;