Reputation: 3324
I am trying to create a user control for my WinRT app, and for that I created a class library in my solution. The class library has a folder named "Images" with an icon.png in it. In the Generic.xaml file, in the controls template I have this:
<Style TargetType="local:MyControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MyControl">
<Button Background="Transparent">
<StackPanel HorizontalAlignment="Center">
<Image Source="/Images/icon.png" Width="64" Height="64"/>
</StackPanel>
</Button>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
When I use this control in the app no image is displaying. I dont know what the problem is. I have tried using ms-appx, and ../ but nothing works. The images Build Options are set to Content.
Upvotes: 0
Views: 323
Reputation: 31724
You would need to use the following format instead:
Source="ms-appx:///MyLibrary/Images/icon.png" />
replacing MyLibrary with the name of your dll.
Upvotes: 2