1

在我的数据绑定(有点高级)列表框中,我实现了一个上下文菜单。但是,当我点击并按住 ListBoxItem 时,ContextMenu 基本上只是弹出 - 没有漂亮的小下拉动画 - 这是我第一次在 ListBoxItem 上执行此操作。第二次(以及之后的每次)都可以正常工作。

我什至不知道如何调试这个 - 有人有任何想法吗?

这是一些示例 XAML:

<ListBox ItemsSource="{Binding ItemList}" Margin="0,0,0,30" ScrollViewer.VerticalScrollBarVisibility="Hidden" x:Name="TodayList" SelectionChanged="handler">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <ListBoxItem>
                <StackPanel Height="88" Margin="12,0,0,0">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu BorderBrush="Black" Background="Black">
                            <toolkit:MenuItem Header="choice1" Foreground="White" Click="handler" />
                            <toolkit:MenuItem Header="choice2" Foreground="White" Click="handler" />
                            <toolkit:MenuItem Header="choice3" Foreground="White" Click="handler" />
                            <toolkit:MenuItem Header="choice4" Foreground="White" Click="handler" />
                        </toolkit:ContextMenu>
                     </toolkit:ContextMenuService.ContextMenu>
                     <TextBlock Style="{StaticResource YellowMedium}" Margin="0,0,0,-4" Text="{Binding Title}" />
                     <TextBlock Style="{StaticResource SubtleText}" Text="{Binding TimeOnChannel}" />
                 </StackPanel>
             </ListBoxItem>
         </DataTemplate>
     </ListBox.ItemTemplate>
</ListBox>
4

1 回答 1

0

有一个区别我已经从数据模板中删除了 ListBoxItem 标记试试这个

<ListBox ItemsSource="{Binding ItemList}" Margin="0,0,0,30" ScrollViewer.VerticalScrollBarVisibility="Hidden" x:Name="TodayList" SelectionChanged="handler">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Height="88" Margin="12,0,0,0">
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu BorderBrush="Black" Background="Black">
<toolkit:MenuItem Header="choice1" Foreground="White" Click="handler" />
<toolkit:MenuItem Header="choice2" Foreground="White" Click="handler" />
<toolkit:MenuItem Header="choice3" Foreground="White" Click="handler" />
<toolkit:MenuItem Header="choice4" Foreground="White" Click="handler" />
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<TextBlock Style="{StaticResource YellowMedium}" Margin="0,0,0,-4" Text="{Binding Title}" />
 <TextBlock Style="{StaticResource SubtleText}" Text="{Binding TimeOnChannel}" />
 </StackPanel>
 </DataTemplate>
 </ListBox.ItemTemplate>
 </ListBox>
于 2012-07-05T09:19:16.767 回答