{"id":630,"date":"2016-11-18T15:28:41","date_gmt":"2016-11-18T15:28:41","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=91"},"modified":"2022-09-13T15:34:49","modified_gmt":"2022-09-13T14:34:49","slug":"images-general","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/images-uwp-programming-in-c\/images-general","title":{"rendered":".Images General"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Add an image<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\t&lt;Image Source =\"Assets\/test_image1.png\" Stretch=\"UniformToFill\" \/&gt;\n\t&lt;Image Source =\"Assets\/Background.png\" Stretch=\"UniformToFill\" HorizontalAlignment=\"Center\" VerticalAlignment=\"Center\" \/&gt;\n\n\t&lt;Image Canvas.Left=\"380\" Canvas.Top=\"198\" Width=\"40\" Height=\"40\" Source=\"Assets\/Icon_Loading.png\" x:Name=\"LoadingIcon\"  \/&gt;<\/code><\/pre>\n\n\n\n<p>Stretch options:\n<\/p>\n\n\n\n<p>None &#8211; No scaling is done.<br>\nFill &#8211; Image will fill the space and aspect ratio is ignored.<br>\nUniform &#8211; Show the entire image with blank space in&nbsp;one axis if needed.<br>\nUniformToFill &#8211; Ensure the whole space is filled and the aspect ration is preserved, cropping if necessary.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Adding image files to the assets folder<\/h4>\n\n\n\n<p>You need to right click the Assets folder in Visual Studio and select Add existing item (you can&#8217;t just copy files into the folder in explorer)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Image From Local Folder<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>img.Source = new BitmapImage(new Uri(\"ms-appdata:\/\/\/local\/SomeFolder\/Logo.png\"));<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Spreading across whole grid<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\t&lt;Image Source=\"MyImage.png\" Stretch=\"UniformToFill\" Grid.ColumnSpan=\"999\" Grid.RowSpan=\"999\"\/&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Changing Image Without Blanking<\/h4>\n\n\n\n<p>Preloading the image doesn&#8217;t seem to work, the workaround until this gets fixed seems to be to have 2 images, one set to collapsed. &nbsp;When you want to display a new image set the collapsed visibility one to show it and create a method for its ImageOpened event which makes it visible and collapses the visibility of the other. &nbsp;Dull, but does the job<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Add an image Stretch options: None &#8211; No scaling is done. Fill &#8211; Image will fill the space and aspect ratio is ignored. Uniform &#8211; Show the entire image with blank space in&nbsp;one axis if needed. UniformToFill &#8211; Ensure the whole space is filled and the aspect ration is preserved, cropping if necessary. Adding image [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[134],"tags":[],"class_list":["post-630","post","type-post","status-publish","format-standard","hentry","category-images-uwp-programming-in-c"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=630"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/630\/revisions"}],"predecessor-version":[{"id":1176,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/630\/revisions\/1176"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}