0
我試過了一切,但我無法在GridView中激發我的圖像上的命令..我忘了什麼嗎?添加Tapped命令事件到一個GridView中的圖像
正如你可以看到它是顯示器的一些圖片horizontaly一個gridview,但我想,如果你在一個你去detailscreen在那裏你可以放大圖像挖掘..
XAML代碼:
<GridView ItemsSource="{Binding SelectedActivity.ObjectAttachments}"
Margin="10,0,0,0"
IsHitTestVisible="False"
Grid.Row="1"
Height="200">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding AttachmentImageSource}"
Width="150"
Height="150"
Stretch="UniformToFill"
Margin="0,10,10,0">
</Image>
</DataTemplate>
</GridView.ItemTemplate>
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Tapped">
<core:InvokeCommandAction Command="{Binding TappedCommand}" />
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
</GridView>
C#代碼隱藏:
public RelayCommand TappedCommand
{
get
{
return new RelayCommand(() =>
{
MessageDialog msgbox = new MessageDialog("Message Box is displayed");
msgbox.ShowAsync();
//do stuff when it works
});
}
}
確實就是這樣,我如何將「AttachmentImageSource」圖像的值傳遞給ViewModel? – Bayern