[英]Windows phone side menu for a listboxitem
I want to create a side menu for a specific listboxitem or longlistselector's item like the picture 我想为特定的listboxitem或longlistselector的项目(如图片)创建侧面菜单
when your press and hold the listboxitem the blue panel comes out, is there anyway to this ? 当您按住listboxitem时,蓝色面板会出现,这是否有帮助?
I managed the Hold event on the item, but not the side menu ! 我管理了该项目的Hold事件,但没有管理侧面菜单!
You can include this menu in your Item Template
and set its Visibility
to Collapsed
. 您可以将此菜单包含在Item Template
,并将其Visibility
设置为Collapsed
。 And then add code to your Hold
event that will show it. 然后将代码添加到您的Hold
事件中以显示它。 Take a look at Storyboard
class for possible animations. 看一下Storyboard
类中可能的动画。
There are a few possible ways to do this, but the basic idea is that you add the menu in a hidden or collapsed state, and then trigger an animation on the Hold event. 有几种方法可以执行此操作,但是基本思想是您将菜单添加为隐藏或折叠状态,然后在Hold事件上触发动画。 Here is a simple example (using the interactivity DLLs System.Windows.Interactivity and Microsoft.Expression.Interactions.Core): 这是一个简单的示例(使用交互DLL System.Windows.Interactivity和Microsoft.Expression.Interactions.Core):
<Grid xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions">
<Grid.Resources>
<Storyboard x:Name="ShowMenu">
<DoubleAnimation Storyboard.TargetName="translate" Storyboard.TargetProperty="X"
To="0" Duration="0:0:0.3" />
</Storyboard>
<Storyboard x:Name="HideMenu">
<DoubleAnimation Storyboard.TargetName="translate" Storyboard.TargetProperty="X"
To="-300" Duration="0:0:0.3" />
</Storyboard>
</Grid.Resources>
<Grid Width="300" Background="LightBlue">
<Grid.RenderTransform>
<TranslateTransform x:Name="translate" X="-300" />
</Grid.RenderTransform>
<!-- Menu popup content here -->
<TextBlock Text="Menu">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Hold">
<ei:ControlStoryboardAction Storyboard="{StaticResource HideMenu}" ControlStoryboardOption="Play" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
</Grid>
<Grid>
<!-- Item content here -->
<TextBlock Text="Item">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Hold">
<ei:ControlStoryboardAction Storyboard="{StaticResource ShowMenu}" ControlStoryboardOption="Play" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock
</Grid>
</Grid>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.