A self maded Xaml customized control has a binded image in a data template via the source property to an object. In this case a BitmapImage like this:
Code behind:
enter public BitmapImage Icon => new BitmapImage(new Uri($"ms-appx:///Assets/{Tag.IconFileName}"));
Xaml:
<ListView ItemsSource="{x:Bind BiTaggedElements, Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="content:TaggedElement">
<!-- List item -->
<Grid Margin="0,0,0,5">
<Grid.RowDefinitions>
<RowDefinition Height="5" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="5" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Image
Width="48"
Height="48"
Margin="0,0,10,0"
Source="{x:Bind Icon}"/>
<TextBlock Margin="0,0,10,0" Text="{x:Bind Title}" />
<TextBlock Margin="0,0,10,0" Text="{x:Bind Origin}" />
</StackPanel>
<TextBlock Grid.Row="2" Text="{x:Bind Note}"></TextBlock>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView
In the end, this customized control is packed by nutget. The image files are included in the nuget nuspec file.
The problem is, i don't now the way to have an access to the assets folder in the customized control environment. In the example above, the image file needs to be in the assets folder of the main app. This customized control is implemented in a own uwp library project (ClassLibrary Uwp). This code in a main app works good.
hope to find a solution, thanks!