In the following code, I use an OpenFileDialog to select an image to place on Canvas1, which I added in the designer.
This works fine except for very large images -- usually somewhere over 32 MegaPixels, though that varies from run to run. When it goes wrong, the Window fails to render. Here's an example:
Private _Image As New Image
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim ofd As New Microsoft.Win32.OpenFileDialog
If ofd.ShowDialog = True Then
Dim bi As New BitmapImage
bi.UriSource = New Uri(ofd.FileName)
_Image.Source = bi
'Me.InvalidateArrange() 'tried this, didn't help.
If I drag other windows over the corrupt window, they leave trails. But immediately I start to drag the WPF window itself by its title bar, it renders correctly. Can anyone suggest a way to deal with this in code?