Hallo,
ich möchte ein Image aus einem Assembly, in dem es als Resource einkompiliert ist, programmatisch laden. Im XAML-Code kann man das bekanntlich so machen:
<Image Source="/MyResourcesAssembly;component/icons/myimage.png" Width="16" Height="16" ... />
Wenn ich das ganze nun programmtisch versuche mit:
C#-Quelltext
1: 2: 3: 4: 5: 6:
| private Image m_Image; ... BitmapImage img = new BitmapImage(new Uri("/MyResourcesAssembly;component/icons/myimage.png")); m_Image = new System.Windows.Controls.Image(); m_Image.Source = img; ... |
dann kommt es zur Exception, weil die URI in einen Filesystem-Pfad übersetzt wird. Was ich aber tun möchte, ist das Image aus dem Assembly laden. DAs Image ist nicht im Resourcen-Objekt des Assembly eingetragen, sondern als Datei hinzugefügt und hat den Typ "Resource", wird also mit einkompiliert.
danke
rijn
Moderiert von
Christian S.: C#-Tags hinzugefügt