使用phone:LongListSelector时需要删除item的功能,我响应了hold事件,但是里面总是获取不到我的item,Item是个类,然后我想生成个toolkit的contextMenu,可是引入了
Microsoft.Phone.Controls.Toolkit。dll后,就编不过了,系统提示,LongListSelector同时存在在phone.dll和toolkit.dll中,该怎么变,
我就想删除某一项,不用SelectionChanged事件,因为响应这个事件时我需要跳到详细界面。请问该怎么做
这是我的xmal文件
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,238,12,0">
<ListBox x:Name="MainLongListSelector" Margin="0,0,-12,0" ItemsSource="{Binding DuplicateContacts}" SelectionChanged="MainLongListSelector_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding DisplayName}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding FamilyName}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource
PhoneTextSubtleStyle}"/>
<!-- -->
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem Header="delete" Click="MenuItem_Click"/>
<toolkit:MenuItem Header="edit" Click="MenuItem_add"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
其中
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
MenuItem menuitem = (MenuItem)sender; //sender为空
Item item = MainLongListSelector.SelectedItem as Item ;
}
why?