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:Code:Class MainWindow 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 Canvas1.Children.Remove(_Image) Dim bi As New BitmapImage bi.BeginInit() bi.UriSource = New Uri(ofd.FileName) bi.EndInit() _Image.Source = bi Canvas1.Children.Add(_Image) 'Me.InvalidateArrange() 'tried this, didn't help. End If End Sub End Class
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?
BB


Reply With Quote