c# - In my WPF application, my loaded PNG logo in image shows at design time but not at run time -


It is probably something simple that I remember I have a PNG file that I have in my WPF window * Image * I want to use as a source of control. I added this project property> resource> existing file and added it as a linked file (and then when it was not working as an embedded) by adding this PNG file. Then I will add * source * to the image to control it in XAML file. No code is included, simple click

The annoying problem is that when I'm designing the WPF window, the image shows when I run it, it doesnt. Nothing appears.

Update: Added XAMLL code

   below < Window x: orbit = "server.mainwindow" xmlns = "http://schemas.microsoft.com/enfx/ 2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/ Xaml "title =" server "height =" 467.91 "width =" 620.522 "& gt; & Lt; Grid & gt; & Lt; Grid.Background & gt; & Lt; LinearGradientBrush EndPoint = "0.5,1" Start Page = "0.5,0" & gt; & Lt; GradientStop color = "#FF080C59" offset = "0" /> & Lt; GradientStop color = "white" offset = "1" /> & Lt; / LinearGradientBrush & gt; & Lt; /Grid.Background> & Lt; Button x: name = "btn connect" content = "connect" horizontal alignment = "left" height = "30" margin = "425,34,0,0" workspaceElement = "top" width = "134" click = "BTN Connect-link "" /> button x: name = "btn disconnected" content = "disconnect" horizontal alignment = "left" height = "35" margin = "425,69,0,0" vertical alignment = "Top" width = "134" click = "btn diskconnect_list" /> gt; textbllock x: name = "txtlog" horizontal align = "left "Margin =" 416,160,0,0 "textvapping =" wrap "vertical alignment =" top "height =" 161 "width =" 87 "background =" #FFFFF 5F5 "text =" log in: "/> ; & Lt; text box x: name = "txtMsg" horizontal alignment = "left" height = "23" margin = "416,326,0,0" textvapping = "wrap" text = "text box" vertical element = "top" width = "112" /> gt; button x: name = "btnandend" content = "send" horizontal alignment = "left" height = "35" margin = "425,120,0,0" vertical Inement = "top" width = "134" Click = "Bitiansandji" / "& gt; & Lt; ListView x: name = "lsvClients" height = "67" margin = "46,212,260,0" vertical alignment = "top" & gt; & Lt; ListView.View & gt; & Lt; GridView & gt; & Lt; GridViewColumn / & gt; & Lt; / GridView & gt; & Lt; /ListView.View> & Lt; / ListView & gt; & Lt; Image horizontal alignment = "left" height = "100" margin = "31,10,0,0" vertical alignment = "top" width = "101" source = "pack: // cytoophorigin: ,,,, images / ServerMainLogo Png "/> & Lt; / Grid & gt; & Lt; / Window & gt;  

What am I missing? Thank you

When you specify image URI in XAML, then typing a full URI is not usually necessary . In addition to the full packed URI shown in the second reply, you should be able to write it:

  & lt; Image ... source = "picture / server_man .png" /> However, you have to make sure that the image file is located in your Visual Studio project folder called  images  and it's set to   

P>

Optionally you build action to content and copy output directory to always copy Or if copy is new . In this case the image has not been embedded as a resource in the assembly of the program, rather it is copied to any directory relative to the executable file.

In XAML (relative) image urr will work in both cases.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -