0

I have a WPF user control that contains a Canvas control, and on that control I want to tile an image that is the same height as the control, but not as wide. I've managed to do it with this code:

        ImageBrush brush = new ImageBrush();
        brush.ImageSource = new BitmapImage(new Uri(System.AppDomain.CurrentDomain.BaseDirectory + "\\res\\01.PNG"));
        brush.TileMode = TileMode.Tile;
        brush.ViewportUnits = BrushMappingMode.Absolute;
        brush.Viewport = new Rect(0, 0, brush.ImageSource.Width, brush.ImageSource.Height);
        brush.Stretch = Stretch.None;

        bkgCanvas.Background = brush;

But, when I run this, the image is zoomed in a small amount, so that it is bigger than it's actual size. I need it to display at actual size with no zoom.

  • http://blogs.msdn.com/b/dwayneneed/archive/2007/10/05/blurry-bitmaps.aspx http://stackoverflow.com/questions/3055550/wpf-how-to-display-an-image-at-its-original-size – Abin Jul 08 '15 at 18:01
  • There are lots of reasons this could be happening. The links provided in the previous comment might help. Or there might be something else going on. In any case, without [a good, _minimal_, _complete_ code example](https://stackoverflow.com/help/mcve) that reliably reproduces the problem, you are unlikely to get a good, useful answer. – Peter Duniho Jul 08 '15 at 18:08

0 Answers0