リストボックスでポップアップを追加する
<Popup Name="textSelectionMenuPopup">
<ListBox Name="textSelectionMenu" Margin="0,0,0,100" ItemContainerStyle="{StaticResource myLBStyle}" SelectionChanged="OnTextSelectionMenuSelectionChanged">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBoxItem Content="Copy">
<ListBoxItem.Background>
<ImageBrush ImageSource="/Images/Copy.png"/>
</ListBoxItem.Background>
</ListBoxItem>
<ListBoxItem Content="Highlights">
<ListBoxItem.Background>
<ImageBrush ImageSource="/Images/Highlights.png"/>
</ListBoxItem.Background>
</ListBoxItem>
<ListBoxItem Content="Tag">
<ListBoxItem.Background>
<ImageBrush ImageSource="/Images/Tag.png"/>
</ListBoxItem.Background>
</ListBoxItem>
<ListBoxItem Content="Note">
<ListBoxItem.Background>
<ImageBrush ImageSource="/Images/Note.png"/>
</ListBoxItem.Background>
</ListBoxItem>
</ListBox>
</Popup>
OnTextSelectionMenuSelectionChanged を処理します。
void OnTextSelectionMenuSelectionChanged(object sender, SelectionChangedEventArgs args)
{
ListBox lstbox = sender as ListBox;
if (lstbox.SelectedItem != null)
{
textSelectionMenuPopup.IsOpen = false;
string command = (lstbox.SelectedItem as ListBoxItem).Content as string;
switch (command)
{
case "Copy":
break;
case "Highlights":
break;
case "Tag":
break;
case "Note":
break;
case "cancel":
break;
}
}