2015-01-31 93 views
0

由于ItemTemplateSelector,我有一个ListView由具有不同样式的项目填充。该的DataTemplates被放置在App.xaml中像下面ressources:App.xaml的DataTemplate上的事件处理程序Windows Phone 8.1

<DataTemplate x:Key="FollowingOuterTemplate"> 
     <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"> 
      <FlyoutBase.AttachedFlyout> 
       <MenuFlyout> 
        <MenuFlyoutItem Text="Delete" /> 
        <MenuFlyoutItem Text="Refresh" /> 
        <MenuFlyoutItem Text="Share" /> 
       </MenuFlyout> 
      </FlyoutBase.AttachedFlyout> 
      <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"> 
       <StackPanel Orientation="Vertical" Width="282"> 
        <TextBlock Grid.Row="0" FontSize="33" Text="{Binding Pseudo}" Foreground="Gray" Height="46" Margin="0,0,-0.333,0"/> 
        <TextBlock Grid.Row="1" FontSize="20" Text="{Binding NomPrenom}" Foreground="#5bc5eb" Height="27" Margin="0,0,-0.333,0"/> 
        <TextBlock Grid.Row="2" FontSize="20" Text="Appuyez pour ne plus suivre" Foreground="#BCC6CC" Height="27" Margin="0,0,-0.333,0"/> 
       </StackPanel> 
       <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" Width="113"> 
        <Image Name="StatutContact" Height="43" Source="/Ressources/Images/checkedTests2.png" Stretch="Fill" Margin="0,20,0,0" Width="44" HorizontalAlignment="Center"/> 
       </StackPanel> 
      </StackPanel> 
     </StackPanel> 
    </DataTemplate> 

所以现在我想显示FlyoutBase连接菜单当我抱着一个项目。但是由于DataTemplate在app.xaml中,并且禁止在其中添加事件处理程序(app.xaml.cs没有任何构造函数,因为它不构造页面)。我想添加一个事件处理程序添加到FyloutBase菜单附加到的StackPanel。

任何人都知道如何做到这一点?

回答

0

不确定你真的不能这样做,但Shawn Kendrot提出了一个Silverlight工具包的ContextMenuService端口来解决你的问题on his Blog.

相关问题