ContextMenu动画不一致

时间:2012-07-05 06:55:10

标签: windows-phone-7 animation listbox

在我的数据绑定(稍微高级)ListBox中,我实现了一个上下文菜单。当我点击并按住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>

1 个答案:

答案 0 :(得分:0)

我已经从datatemplate中删除了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>