我试图显示存储在XAML设计内部本地目录中的图像。
我有路径局部图像。
ImagePage.xaml
<ScrollViewer>
<ListView x:Name="ViewImage" SelectionMode="None" IsActiveView="True">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" MaximumRowsOrColumns="1" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid x:Name="imgGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel>
<Grid Height="50" Width="50">
<Grid Margin="2" Background="red">
<Image Source="{Binding imgArt}" Stretch="UniformToFill"
Height="40" Width="40"/>
</Grid>
</Grid>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollViewer>
ImagePage.xaml.cs
string strImgPath = "ms-appx:///Images/Music/localImg.png";
public string imgPath
{
get { return strImgPath; }
}
imageClaz obj = new imageClaz();
obj.imgArt = imgPath;
imageClaz()
public class imageClaz
{
public string imgArt { get; set; }
}