Reputation: 1093
I have a file called AppResources.resx in my project and I am able to put strings in there for localization purposes. I can then access them via binding as such;
Header="{Binding Path=LocalizedResources.MyString, Source={StaticResource LocalizedStrings}}
You are also able to add images to this resource file, but I cannot figure out how to bind to the images I put in there! Is there a way? Should I not be putting images in this file?
Thanks for any pointers.
Upvotes: 1
Views: 211
Reputation: 9240
You can create an image brush in ResourceDictionary:
<ImageBrush x:Key="MyImageBrush" ImageSource="/Img-1.jpg"/>
And you can call it to set as a background, or as a Fill for rectangle:
<Rectangle x:Name="ImageForeground" Height="100" Width="100"
Fill="{StaticResource MyImageBrush}" />
Other option is to use a special converter, like it is described here.
This ways are suitable for images wich are not localizable.
If you want to set different images for different cultures, you can try this way. Not sure if it works for windows phone, but it works for Silverlight.
Upvotes: 1