Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SafePicture : System.Windows.Controls.ContentControl
- {
- private ImageSource imageSource;
- public SafePicture()
- {
- Loaded += OnLoaded;
- Unloaded += SafePictureUnloaded;
- }
- private void OnLoaded(object _sender, RoutedEventArgs _routedEventArgs)
- {
- var image = Content as System.Windows.Controls.Image;
- if (imageSource != null && image != null)
- image.Source = imageSource;
- }
- private void SafePictureUnloaded(object sender, System.Windows.RoutedEventArgs e)
- {
- var image = Content as System.Windows.Controls.Image;
- if (image != null)
- {
- imageSource = image.Source;
- image.Source = null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment