2015-01-31 91 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.

相關問題