몇 가지 예에서 나는이 일을 제대로하고 있다고 생각하지만 작동하지 않아 여기를 확인하고 싶습니다. 이미지 소스를 바인딩하고 있지만 이미지가 없습니다. 바인딩을 제거하고 아래의 메서드에서 사용 된 경로로 이미지 소스를 설정하면 올바르게 작동합니다.이미지 원본을 바인딩하는 방법?
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" />
Ts, 나는 반 분 더 빨랐다. ( –
@HB, 죄송합니다. 답변을 못 알아 들었습니다. +1은 그것을 보충합니다.) –
하하, 고마워, 어쨌든, 네 잘못이 아니야. 동시 대답은 많이 발생합니다. –