问题
BitmapImage B = new BitmapImage();
B.BeginInit();
B.StreamSource = asm.GetManifestResourceStream("WpfApplication26.Back1.png");
B.EndInit();
image1.Source = B;
The size of the image (Back1.png) is 32*32, and I set the size of my image control to 32*32 and set the property "Scale" to "None".
回答1:
Try
RenderOptions.BitmapScalingMode="NearestNeighbor"
on the image control in xaml or
RenderOptions.SetBitmapScalingMode(image1, BitmapScalingMode.NearestNeighbor)
in code.
回答2:
Try SnapsToDevicePixels="True"
on the image control.
回答3:
If you still want to clear the image, meaning, turning it to blank, just set the source to "null"
image1.Source = null;
This does not require a BitmapImage.
Sorry for the late reply...
来源:https://stackoverflow.com/questions/4684052/why-isnt-the-image-in-my-image-control-clear