从一些例子来看,我认为我这样做是正确的,但它没有用,所以我想在这里查看.我绑定了我的图像源,但图像不在那里.如果我拿走我的绑定并将Image源设置为下面方法中使用的路径,它可以正常工作.
public Image myImage = new Image();
public void someMethod() {
BitmapImage biSource = new BitmapImage();
biSource.BeginInit();
biSource.CacheOption = BitmapCacheOption.OnLoad;
biSource.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
biSource.UriSource = new Uri(@"C:\Images\testimage.jpg");
biSource.DecodePixelWidth = 150;
biSource.EndInit();
myImage.Source = biSource;
}
xaml code
<Image Source="{Binding Path=myImage}" Width="150" Height="150" />
Run Code Online (Sandbox Code Playgroud)