2014-03-26 12 views
0

我得到了一個水平的ListBox來顯示圖片。我想在每個項目上添加一個ContextMenu,允許用戶刪除該項目。但我不知道我的ContextMenu在我的ItemTemplate中的確切位置,我幾乎在任何地方嘗試過,但ContextMenu從不在Holding上顯示。 你知道在哪裏放置XAML組?列表框中的WP8 ContextMenu沒有顯示

<ListBox x:Name="PhotoListBox" Grid.Row="1" ItemsSource="{Binding}" SelectionChanged="PhotoListBox_SelectionChanged" > 
      <ListBox.ItemsPanel> 
       <ItemsPanelTemplate> 
        <toolkit:WrapPanel 
         HorizontalAlignment="Left" 
         Margin="0,0,0,0" 
         VerticalAlignment="Top" 
          /> 
       </ItemsPanelTemplate> 
      </ListBox.ItemsPanel> 
      <ListBox.ItemTemplate> 
       <DataTemplate> 
        <StackPanel Margin="5"> 
         <StackPanel Orientation="Vertical"> 
          <Grid Width="100" Height="100"> 
           <Grid.Background> 
            <ImageBrush Stretch="UniformToFill" ImageSource="{Binding}" /> 
           </Grid.Background> 
           <toolkit:ContextMenu> 
            <toolkit:MenuItem Header="Delete" Click="MenuItem_OnClick"/> 
           </toolkit:ContextMenu> 
          </Grid> 
         </StackPanel> 
        </StackPanel> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 
     </ListBox> 

感謝

回答