我正在尝试为我的WinRT应用程序创建一个用户控件,为此我在我的解决方案中创建了一个类库。 类库有一个名为“Images”的文件夹,里面有一个icon.png。在Generic.xaml文件中,在控件模板中我有:
<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>
当我在应用程序中使用此控件时,不显示任何图像。我不知道问题是什么。我尝试过使用ms-appx和../但没有任何效果。图像构建选项设置为内容。
答案 0 :(得分:2)
您需要使用以下格式:
Source="ms-appx:///MyLibrary/Images/icon.png" />
将myLibrary替换为您的dll名称。