Xaml 在ResourceDictionary控件中添加事件

Xaml 在ResourceDictionary控件中添加事件,xaml,windows-phone-7,windows-phone-8,Xaml,Windows Phone 7,Windows Phone 8,我必须在ResourceDictionary中reides的控件中添加事件,例如列表选择更改图像点击等,请建议cna我如何执行此操作 <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"

我必须在ResourceDictionary中reides的控件中添加事件,例如列表选择更改图像点击等,请建议cna我如何执行此操作

                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>
视图->主页.XAML

<Grid x:Name="LayoutRoot" Background="{StaticResource AppBackgroundColor}">
  <phone:Panorama Name="Container" Grid.Row="0" ItemsSource="{Binding}" SelectionChanged="OnSelectionChanged" toolkit:TiltEffect.IsTiltEnabled="True"
                  Background="{StaticResource AppBackground}" TitleTemplate="{StaticResource AppPanoramaTitle}">

      <phone:PanoramaItem Name="GetGalleryItem" Content="{Binding GetGalleryModel}" ContentTemplate="{StaticResource GetGalleryContent}"/>
  </phone:Panorama>
                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>

                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>
视图->数据模板->GetGallery.XAML

<Grid x:Name="LayoutRoot" Background="{StaticResource AppBackgroundColor}">
  <phone:Panorama Name="Container" Grid.Row="0" ItemsSource="{Binding}" SelectionChanged="OnSelectionChanged" toolkit:TiltEffect.IsTiltEnabled="True"
                  Background="{StaticResource AppBackground}" TitleTemplate="{StaticResource AppPanoramaTitle}">

      <phone:PanoramaItem Name="GetGalleryItem" Content="{Binding GetGalleryModel}" ContentTemplate="{StaticResource GetGalleryContent}"/>
  </phone:Panorama>
                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>

                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>

                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>


对于图像中的点击事件,您可以在
图像
标记中使用
点击
键。比如

                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>
Xaml:

                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>
是的,您可以对listbox或longlistselector使用
SelectionChanged
事件。 过目

                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>

希望对图像中的点击事件有所帮助

,您可以在
图像
标签中使用
点击
键。
                        <Image Source="{Binding THUMB, Converter = {StaticResource ThumbnailConverter}, ConverterParameter = 120}" Width="120" x:Name="testTap"
                               Height="120" Stretch="Fill" />

                    <Image Source="{Binding CategoryImage}" Width="130" Height="130" Stretch="Fill" />
                </Grid>
            </DataTemplate>
        </controls:LongListSelectorEx.ItemTemplate>
    </controls:LongListSelectorEx>
</DataTemplate>