2011-06-12 74 views
2

就像Fluent.RibbonWindow一樣,我需要控件來粘貼窗口的標題/邊框。
我嘗試從課堂中提取RibbonWindow,但我總是遇到麻煩。我只是不能這樣做...
有人可以幫助我嗎?
我基本上需要將窗口的客戶區擴展到整個窗口。
我需要將客戶區擴展到框架中,不是框架進入客戶區!超出WPF窗口的控件?

回答

2

自定義鑲邊功能允許應用程序控制窗口的外框,以便可以在標題欄上繪製WPF內容。

這聽起來像是你在找什麼:WPF Shell Integration Library

+0

這真的有幫助! :D – Vercas 2011-06-12 22:00:01

1

我曾經將其置於一個無框,最上和最透明的窗口增加了一個Outlook風格的按鈕,將非客戶區。

這是該窗口繼承了基類:

public class WindowHeaderButton : Window 
{ 
    private readonly Window _owner; 

    public WindowHeaderButton(Window owner) 
    { 
     _owner = owner; 
     _owner.Loaded += owner_Loaded; 
     _owner.LocationChanged += owner_LocationChanged; 
     _owner.StateChanged += owner_StateChanged; 
     _owner.SizeChanged += owner_SizeChanged; 
     _owner.Deactivated += _owner_Deactivated; 
     _owner.Activated += _owner_Activated; 
     Activated += WindowHeaderButton_Activated; 
     SizeToContent = SizeToContent.WidthAndHeight; 
     WindowStyle = WindowStyle.None; 
     AllowsTransparency = true; 
     Background = new SolidColorBrush(Colors.Transparent); 
     ShowInTaskbar = false; 
    } 

    void WindowHeaderButton_Activated(object sender, System.EventArgs e) 
    { 
     Opacity = 1; 
    } 

    void _owner_Activated(object sender, System.EventArgs e) 
    { 
     Opacity = 1; 
    } 

    void _owner_Deactivated(object sender, System.EventArgs e) 
    { 
     Opacity = 0.75; 
    } 

    private void owner_Loaded(object sender, RoutedEventArgs e) 
    { 
     Owner = _owner; 
     Show(); 
     UpdatePosition(); 
    } 

    private void owner_SizeChanged(object sender, SizeChangedEventArgs e) 
    { 
     UpdatePosition(); 
    } 

    private void owner_StateChanged(object sender, System.EventArgs e) 
    { 
     UpdatePosition(); 
    } 

    private void owner_LocationChanged(object sender, System.EventArgs e) 
    { 
     UpdatePosition(); 
    } 

    private void UpdatePosition() 
    { 
     Top = _owner.Top + 1; 
     Left = _owner.Left + 8; 
    } 
} 

正如你看到一個有處理很多窗口的行爲樣活性的狀態和位置改變自己,這很容易可以得到一個有點亂。

+0

我不確定這個......這更像是一個小故障。 – Vercas 2011-06-12 22:00:17