1

私のデータバインドされた (やや高度な) ListBox には、コンテキスト メニューが実装されています。ただし、ListBoxItem をタップ アンド ホールドすると、基本的に ContextMenu がポップアップするだけで、ListBoxItem で初めてそれを行うと、小さなドロップダウン アニメーションは表示されません。2 回目 (およびそれ以降は毎回) 正常に動作します。

私はこれをデバッグする方法さえ知りません - 誰かアイデアがありますか?

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 に答える