C# WPF ImageControl not showing selected image -


this question has answer here:

i'm using vs2013. .netframework 3 . i'm writing simple project image gallery. i'm trying add jpeg image image control. first i'm adding test.jpg image resource. i'm adding image control on window. in next step i'm selecting image in "source" property. image displaying design mode. ok. when i'm running project nothing displaying. searched in google , youtube. founded solutions haven't solution problem (sorry eng) here code line

<image source="pack://siteoforigin:,,,/resources/1.jpg" ... /> 

in order display image in wpf app, following:

1). in xaml, add:

<image name="imgname" source="/projassemblyname;component/relativepathtoimagefile" /> 

2). in visual studio ide, select image file , check properties:

build action: resources copy output directory: not copy 

note: in typical case project assembly name same default namespace; check in application property dialog. useful info pertinent case included in microsoft reference (as pointed out member @clemens): https://msdn.microsoft.com/en-us/library/aa970069%28v=vs.110%29.aspx#resource_file_pack_uris___local_assembly.).

another option set image build action property embeddedresource , bitmapimage object corresponding image file programmatically following:

bitmapimage _bmpimage = new bitmapimage(); _bmpimage.begininit(); _bmpimage.streamsource = assembly.getexecutingassembly().getmanifestresourcestream(string.concat(projassemblyname, imgfile)); _bmpimage.endinit(); 

this technique useful if further image processing considered.

hope may help. kind regards,


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -