2010-10-30 115 views
2

由於Here的鏈接是一個很好的對接應用程序,但我需要類似Mac OSX上碼頭,它會靠在側面沒有采取一畫面,當我們需要它的存在。對接,例如Mac OSX Dock中的WPF

請告訴我對接的解決方案,不佔用屏幕空間。

回答

0

下面是一個在黑暗中拍攝,基於我想像你正在努力實現的。我假設你正在運行基於窗口的完全信任本地應用程序。信任可能無關緊要,只是設定背景。

有三件我想象的解決方案:

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'> 
+0

謝謝你的解決方案,而遺憾的是,我無法解釋我想要的東西,這是它「我只是需要它停靠在桌面的任何一邊,應該表現得像在Mac OSX Dock或將戴爾Dock「。對不起,再次感謝您的幫助! – Alam 2010-10-30 09:19:53

+0

沒有問題,現在答案更新,以反映需求。 – 2010-10-30 10:02:11

+0

很好,我會嘗試一下,謝謝。 – Alam 2010-10-30 10:49:08