1

I'm using PrintDialog.PrintVisual() to print my viewmodel. For this I use binding on a dictionary:

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="329" Height="204">
    <Image Source="{Binding Details.Properties[Imagedata].ImageStream}" Stretch="Fill" Width="95" Height="122" Canvas.Left="14" Canvas.Top="41"/>
    <Image Source="{Binding Details.Properties[Signature].ImageStream}" Stretch="Fill" Height="25" Width="100" Canvas.Left="122" Canvas.Top="143"/>
</Canvas>

If I put this Canvas on my WPF window, it's showing fine. But if I want to print it, it's using the first image on my second image. In debugger I checked after UpdateLayout the Image.Source - both are right. The next step is PrintDialog.Printvisual(canvas, "print"); The output is as described but not the same every time. Sometimes the first image is even repeated in the second Image.

Why does this happen?

UPDATE: I found a workaround: I search for all Image elements, copy the ImageSource into a MemoryStream and create a new BitmapImage out of it. It's not nice, but it works right now. If anybody could explain, why this works, it would be great.

Matt
  • 4,612
  • 1
  • 24
  • 44
  • Using threading somewhere in print operation? – Renatas M. Jan 14 '15 at 11:33
  • Yes, we use come threads caused by architecture. Is there a way without avoiding threads? – Matt Jan 14 '15 at 11:53
  • I experienced a similar behavior but - strange enough - only when I test with XPS file printer. When I select my actual printer it works. Would be interested in any non-hack solution – grek40 Nov 30 '15 at 15:14
  • @Matt, maybe the explanation you are looking for can be this by André Rocheleau here: [link](https://stackoverflow.com/questions/30523815/duplicate-images-printed-in-xps-file) – IamJose Jun 21 '22 at 09:58

0 Answers0