我需要从C#设置Image Source。我试过X:Name="headimg"
,但我找不到C#中的headimg。
<StackPanel x:Name="Body">
<Image x:Name="headimg" Source="img/logo.png" Height="120" Width="130" HorizontalAlignment="Left"></Image>
</StackPanel>
答案 0 :(得分:0)
试试这个:
public void SetImage()
{
BitmapImage imge = new BitmapImage(new Uri("/Assets/Images/ImageName.png", UriKind.Relative));
headimg.Source=image.Source;
}