나는 이것이 쉬운 질문이지만, 알아낼 수 없거나 대답을 찾을 수 없다는 것을 알고 있습니다. 난 그냥 C#을 사용하여 WPF에서 런타임 중에 이미지 소스를 변경하려고합니다. 코드가 실행될 때마다 2.gif를 표시하는 대신 1.gif 만 제거하고 빈 흰색 상자가 나타납니다. 미리 감사드립니다.wpf 변경 이미지 소스
XAML :
<Image x:Name="img" Height="150" Margin="142,20,138,0" VerticalAlignment="Top">
<Image.Source>
<BitmapImage UriSource="C:\Users\John\1.gif" />
</Image.Source>
</Image>
C 번호 :
string sUri = @"C:\Users\John\2.gif";
Uri src = new Uri(sUri, UriKind.RelativeOrAbsolute);
BitmapImage bmp = new BitmapImage(src);
img.Source = bmp;
'높이'가 설정되었지만 '이미지'에 맞게 '너비'늘이기를 할 수 있습니까? – Yogesh