鼠标悬停菜单就像visual studio中的工具栏一样

时间:2012-09-05 13:30:16

标签: c# wpf

我试图找出是否有可能实现弹出包含数据网格的面板,鼠标悬停在“扩展器”位上。

寻找与visual studio中的工具箱一样的东西。

我在搜索时遇到了重大问题,我不确定它的名字。

如果我需要更好地解释自己,请告诉我。

2 个答案:

答案 0 :(得分:1)

您可以使用AvalonDock来实现此目标

enter image description here

这是在XAML中使用以下代码完成的:

<avalondock:DockingManager x:Name="dockingManager">
    <avalondock:LayoutRoot>
        <avalondock:LayoutRoot.LeftSide>
            <avalondock:LayoutAnchorSide>
                <avalondock:LayoutAnchorGroup>
                    <avalondock:LayoutAnchorable Title="Autohidden Content">
                        <DataGrid>
                            <DataGrid.Columns>
                                <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" Header="Col1"/>
                                <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" Header="Col2"/>
                                <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" Header="Col3"/>
                            </DataGrid.Columns>
                        </DataGrid>
                    </avalondock:LayoutAnchorable>
                </avalondock:LayoutAnchorGroup>
            </avalondock:LayoutAnchorSide>
        </avalondock:LayoutRoot.LeftSide>
    </avalondock:LayoutRoot>
</avalondock:DockingManager>

答案 1 :(得分:0)

我会帮助WPF动画实现任何类型的菜单弹出/出现/滑动/以某种方式顺利进行。

以您想要的任何方式构建菜单控件,例如基于StackPanel,然后为其位置属性分配一些自定义动画,使其显示和消失。

动画的使用非常简单,因为您只是为特定属性指定了开始值,目标值以及在这两者之间进行转换的方法。

例如,为了使Stackpanel增长和缩小,您可以执行以下操作:

// suppose you have a stackpanel named sp.

// create the actual animation
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = 100;
myDoubleAnimation.To = 300;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));

// cerate the storyboard which comprise all your single animations into a compound animation - a storyboard.
StoryBoard myStoryboard = new Storyboard();
myStoryboard.Children.Add(myDoubleAnimation);

// link the animation with the object it is supposed to work on
Storyboard.SetTargetName(myDoubleAnimation, sp.Name);

// specify the target property of ypur StackPanel which should be affected by the animation
Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Rectangle.Width));

如需完整的介绍,您可以在此处阅读:http://msdn.microsoft.com/en-us/library/ms752312.aspx

另请阅读有关缓动功能的信息,因为在他们的帮助下,您可以构建更复杂的动画。