我有一个贴纸列表,当我 select 此列表中的一个或多个贴纸时,我想要在 uwp 应用程序中的 canvas 上显示贴纸
I have a list of stickers and i want when I select one or more stickers from this list, stickers are display on my canvas in uwp application
<ListView x:Name="Stickers1" Visibility="Collapsed"
SelectionChanged="Stickers1_SelectionChanged"
ScrollViewer.VerticalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="50"
FontSize="36" Margin="0" ItemTemplate="{StaticResource
listStickersDataTemplate}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
<DataTemplate x:Key="listStickersDataTemplate">
<Grid>
<Image Source="{Binding Imageurl}" Stretch="Fill" Height="200" Width="200"/>
</Grid>
</DataTemplate>`
查看您的 Stickers1_SelectionChanged
活动,您似乎没有在 Canvas
中设置 img
的 Source
像下面这样的东西应该可以解决它
private void Stickers1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selecteditem = e.AddedItems[0] as StickersImageListModel;
Stickers1.Visibility = Visibility.Collapsed;
BitmapImage image = new BitmapImage(new System.Uri("ms-appx://" + selecteditem.ImageUrl, UriKind.Absolute));
img.Source = image;
my_canvas.Visibility = Visibility.Visible;
}
<ListView x:Name="Stickers1" Visibility="Collapsed"
SelectionChanged="Stickers1_SelectionChanged"
ScrollViewer.VerticalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="50"
FontSize="36" Margin="0" ItemTemplate="{StaticResource
listStickersDataTemplate}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
<DataTemplate x:Key="listStickersDataTemplate">
<Grid>
<Image Source="{Binding Imageurl}" Stretch="Fill" Height="200" Width="200"/>
</Grid>
</DataTemplate>`
查看您的 Stickers1_SelectionChanged
活动,您似乎没有在 Canvas
img
的 Source
像下面这样的东西应该可以解决它
private void Stickers1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selecteditem = e.AddedItems[0] as StickersImageListModel;
Stickers1.Visibility = Visibility.Collapsed;
BitmapImage image = new BitmapImage(new System.Uri("ms-appx://" + selecteditem.ImageUrl, UriKind.Absolute));
img.Source = image;
my_canvas.Visibility = Visibility.Visible;
}