来自C#XAML的图像源

时间:2014-05-30 10:00:59

标签: xaml windows-phone

我需要从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>

1 个答案:

答案 0 :(得分:0)

试试这个:

public void SetImage()
{
    BitmapImage imge = new BitmapImage(new Uri("/Assets/Images/ImageName.png", UriKind.Relative));
    headimg.Source=image.Source;
}