0

I have a multi project solution in which there is a project holding all the views and one holding the view models. In the project holding the views I have a folder (imaginatively called 'Images') which contains all of the images used in the various views.

Within one particular view I wish to have an image change dynamically at runtime so I have created a property of type System.Windows.Media.Imaging.BitmapImage in that view's view model and bound the imagesource of a button in the view to that property in xaml.

  <!-- Login Button -->
            <ribbon:Button ImageSourceSmall="{Binding Path=SecurityImage}" />

in the constructor of the viewmodel I have the following:

SecurityImage = New BitmapImage(New Uri("/FtpViews/Images/security_lock16.png",UriKind.Relative))

FtpViews is the name of the project containing the views.

If I have the Images folder in the same project as the view model referecing it I can get this to work, but I can't seem to get the uri reference to work correctly if the images folder is in another project in the solution. Either I have the notation of the Uri completely wrong (which is more that possible as I always seem to find that they are often a case of trial and error) or you can't actually reference resources in linked projects in this way.

I'd welcome any thoughts on this.

Thanks

Dom Sinclair
  • 2,458
  • 1
  • 30
  • 47
  • Im using vectors not images, but in my case this is the path I would use. "/YourProjectName;componet/FtpViews/Images/security_lock16.png" – adminSoftDK Mar 06 '15 at 09:05
  • For reference, here is the [Resource File Pack URI](https://msdn.microsoft.com/en-us/library/aa970069(v=vs.110).aspx#Resource_File_Pack_URIs___Local_Assembly) documentation on MSDN. – Clemens Mar 06 '15 at 09:26
  • Thanks Clemens. found out that I was almost there in the first place, should have been SecurityImage = New BitmapImage(New Uri("/FtpViews;component/Images/security_lock16.png", UriKind.RelativeOrAbsolute)) – Dom Sinclair Mar 06 '15 at 15:27

0 Answers0