【发布时间】:2011-05-02 18:02:51
【问题描述】:
因为链接上的Here 是一个不错的停靠应用程序,但我需要类似 Mac OSX 停靠的东西,它停靠在一边而不占用屏幕,当我们需要它时它就在那里。
请告诉我不占用屏幕空间的对接解决方案。
【问题讨论】:
因为链接上的Here 是一个不错的停靠应用程序,但我需要类似 Mac OSX 停靠的东西,它停靠在一边而不占用屏幕,当我们需要它时它就在那里。
请告诉我不占用屏幕空间的对接解决方案。
【问题讨论】:
这是在黑暗中的一个镜头,基于我想象的你想要实现的目标。我将假设您正在运行基于 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'>
【讨论】: