I have an icon on resources that it key is: xxx
I want to bind it to an image in xaml..
1:
<Image Source="{x:Static p:Resources.xxx}"></Image>
2:
<Image>
<Image.Source>
<BitmapImage UriSource="{Binding x:Static p:Resources.xxx}"/>
</Image.Source>
</Image>
3:
<Image Source=" {Binding x:Static p:Resources.xxx,Converter={StaticResource IconToBitmap_Converter}}"></Image>
4:
<Image>
<Image.Source>
<BitmapImage UriSource="{Binding x:Static p:Resources.xxx,Converter={StaticResource IconToBitmap_Converter}}"/>
</Image.Source>
</Image>
The above ways does not work, how am I supposed to do that?
First you must add your Image into a Resource File in the Solution Explorer. Next you must set the Build Action of your Image to Resource and then you can use it in the XAML Code like this:
<UserControl>
<UserControl.Resources>
<ResourceDictionary>
<BitmapImage x:Key="name" UriSource="Resources/yourimage.bmp" />
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Image Source="{StaticResource name}"/>
</Grid>
</UserControl>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With