There is a scrollviewer and an image in my custom image window. The dependecy property The type string image is used to set the image.
public static DependencyProperty ImageProperty = DependencyProperty.Register(
"Image", typeof(string), typeof(CustomPictureBox), new FrameworkPropertyMetadata("", new PropertyChangedCallback(OnImageChanged)));
private static void OnImageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
CustomPictureBox cpb = (CustomPictureBox)d;
if (e.Property == ImageProperty)
{
string newvalue = e.NewValue as string;
if (!(string.IsNullOrEmpty(newvalue)))
{
var bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = new Uri(newvalue);
bmp.CacheOption = BitmapCacheOption.OnLoad;
bmp.EndInit();
cpb.imgPicture.Source = bmp;
}
else
cpb.imgPicture.Source = null;
}
}
"camera_image.tif". Image .
, Image , .
, "camera_image.tif". , . , . , .
, ?
,