Wp7 silverlight toolkit 学习之 ContextMenu使用
xaml:
<Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="156,114,0,0" Name="button1" VerticalAlignment="Top" Width="160" >
??????????????? <toolkit:ContextMenuService.ContextMenu>
??????????????????? <toolkit:ContextMenu Height="300"
???????????????????????????????????????? HorizontalAlignment="Left"
???????????????????????????????????????? Margin="0,0,0,0"
???????????????????????????????????????? Name="contextMenu1"
???????????????????????????????????????? VerticalAlignment="Top"
???????????????????????????????????????? Width="100"
???????????????????????????????????????? Background="Red">
??????????????????????? <toolkit:MenuItem Header="你好" Click="MenuItem_Click">???????????????????????????
??????????????????????? </toolkit:MenuItem>
??????????????????????? <toolkit:Separator></toolkit:Separator>
??????????????????????? <toolkit:MenuItem>
??????????????????????????? <toolkit:MenuItem.Header>
??????????????????????????????? <StackPanel Orientation="Horizontal">
??????????????????????????????????? <Image? Source="/ApplicationIcon.png" ></Image>
??????????????????????????????????? <TextBlock Text="好好学习"></TextBlock>
???????????????????????????????????
??????????????????????????????? </StackPanel>
???????????????????????????????
??????????????????????????? </toolkit:MenuItem.Header>
??????????????????????? </toolkit:MenuItem>
??????????????????? </toolkit:ContextMenu>
??????????????? </toolkit:ContextMenuService.ContextMenu>????????????????
??????????? </Button>
上面红色部门必须加的,contextMenu不能放到容器中用,要和其他控件绑定同时使用,你长按button就会弹出一个菜单,你试下上面代码就知道了
?