2

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

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

4

1 回答 1

0

这是根据我想象的您想要实现的目标在黑暗中拍摄的。我将假设您正在运行基于 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 会对其子级进行测量,但我可能是错的)。

最后,构成码头的项目的结构:

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

(评论交流后)如果你想让它透明地坐在桌面上,你需要这样设置:

<Window WindowStyle='None' Background='Transparent' State='Maximized'>
于 2010-10-30T09:04:46.397 回答