简体   繁体   English

从C#xaml.cs中的项目空间添加图像

[英]Adding image from project space in C# xaml.cs

This is nothing short of embarrassing to ask but I'm having no luck with searches today. 这很令人尴尬,但我今天的搜索工作不走运。

I have an image plane.png which I have added as an existing item to my project "Rem". 我有一个image plane.png图像,它已作为现有项目添加到我的项目“ Rem”中。 I have map.xaml in this, but since I want to add multiple "plane.png" images to this, I am trying to create them in map.xaml.cs 我在其中有map.xaml,但是由于我要为此添加多个“ plane.png”图像,因此我试图在map.xaml.cs中创建它们

The XAML code to do what I want is simply: <Image Source="plane.png"/> 执行我想要的XAML代码很简单: <Image Source="plane.png"/>

Would some kind soul be able to tell me what the C# equivalent to this is? 某种友善的灵魂能够告诉我与此等效的C#是什么吗?

Thanks very much in advance, 首先十分感谢,

M 中号

Image i = new Image();    
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri("plane.png", UriKind.Relative);
bi.EndInit();
i.Source = bi;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM