就像Fluent.RibbonWindow
一样,我需要控件贴在窗口的标题/边框上
我尝试从课程中提取RibbonWindow
,但我总是遇到麻烦。我不能这样做...
有人可以帮我这个吗?
我基本上需要将窗口的客户区扩展到整个窗口
我需要将客户区扩展到框架中,不框架进入客户区!
答案 0 :(得分:2)
自定义镶边功能允许应用程序控制窗口的外框,以便可以在标题栏上绘制WPF内容。
这听起来像你在寻找:WPF Shell Integration Library
答案 1 :(得分: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;
}
}
正如您所注意到的那样,您必须自己处理许多窗口行为,例如活动状态和位置更改,这很容易让人感到麻烦。