【问题标题】:Docking Like Mac OSX Dock in WPF像 WPF 中的 Mac OSX Dock 一样停靠
【发布时间】:2011-05-02 18:02:51
【问题描述】:

因为链接上的Here 是一个不错的停靠应用程序,但我需要类似 Mac OSX 停靠的东西,它停靠在一边而不占用屏幕,当我们需要它时它就在那里。

请告诉我不占用屏幕空间的对接解决方案。

【问题讨论】:

    标签: wpf docking


    【解决方案1】:

    这是在黑暗中的一个镜头,基于我想象的你想要实现的目标。我将假设您正在运行基于 Window 的完全信任本地应用程序。信任可能无关紧要,只是设置上下文。

    我想象的解决方案分为三个部分:

    Window1.xaml (your main app window)
     <Window blah blah>
      <Grid>
      <!--Your application content-->
        <local:PseudoDock VerticalAlignment='Bottom' />
      </Grid>
    </Window>
    
    PseudoDock.xaml
    <UserControl Height='5'>
     <UserControl.Triggers>
      <Trigger Property='FrameworkElement.IsMouseOver'>
       <Setter Property='Height' Value='NaN' />
      </Trigger>
     </UserControl.Triggers>
     <ItemsControl>
      <ItemsControl.ItemsPanelTemplate>
       <StackPanel Orientation='Horizontal' />
      </ItemsControl.ItemsPanelTemplate>
      <ItemsControl.ItemTemplate>
       <DataTemplate>
        <Button Command='{Binding Path=Command}'>
         <StackPanel>
          <Image Source='{Binding Path=Icon}' />
          <TextBlock Source='{Binding Path=Label}' />
         </StackPanel>
        </Button>
       </DataTemplate>
      </ItemsControl.ItemTemplate>
     </ItemsControl>
    </UserControl>
    

    扩展坞的重要之处在于它有 5 像素高,在底部不显眼,并且有一个鼠标悬停可以将其提升到全高。 (您也可以尝试设置一个明确的高度,我想将高度设置为 NaN 会对其子项进行衡量,但我可能是错的)。

    最后,组成dock的项目结构:

    DockItem.cs
    class DockItem{
     ICommand Command{get;set;}
     String Label{get;set;}
     ImageSource Icon{get;set;}
    }
    

    (评论交流后) 如果您希望它透明地位于桌面上,您需要这样设置:

    <Window WindowStyle='None' Background='Transparent' State='Maximized'>
    

    【讨论】:

    • 感谢您的解决方案,很抱歉我未能解释我想要什么,这里是“我只需要它停靠到桌面的任何一侧并且应该像 Mac OSX Dock 或 Dell码头”。很抱歉给您带来麻烦,再次感谢您的帮助!
    • 没问题,现在回答更新以反映要求。
    • 太好了,我试试看,谢谢。
    猜你喜欢
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-24
    • 1970-01-01
    • 1970-01-01
    • 2015-07-20
    • 2017-02-07
    相关资源
    最近更新 更多