有人可以建议如何从顶部实现可拉动视图,以显示WPF中的iOS设备等警报/通知吗?
由于
答案 0 :(得分:1)
很抱歉,花了很长时间才回应,忙于自己的项目。无论如何,最简单的路线就是点击,这很容易。这是一个概念示例;
<Grid>
<Grid.Resources>
<Storyboard x:Key="SlidePanelDown">
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="grid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0"/>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="SlidePanelUp">
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="grid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0,-225,0,0"/>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<Grid.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked" SourceName="button">
<BeginStoryboard Storyboard="{StaticResource SlidePanelDown}"/>
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked" SourceName="button">
<BeginStoryboard x:Name="SlidePanelUp_BeginStoryboard" Storyboard="{StaticResource SlidePanelUp}"/>
</EventTrigger>
</Grid.Triggers>
<Grid x:Name="grid" Width="100" Height="250" VerticalAlignment="Top" Margin="0,-225,0,0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Rectangle Fill="Green"/>
<ToggleButton x:Name="button" Grid.Row="1" Content="Click Me" Cursor="Hand"/>
</Grid>
</Grid>
要让它实际上可以拖动,它需要更多的努力,但如果你真的想要这种效果是可能的,但这应该是一个好的开始。希望这有帮助!
答案 1 :(得分:0)
我使用了弹出控件,这更适合我的情况。您可以找到文档here。