就像 一样Fluent.RibbonWindow
,我需要将控件粘贴在窗口的标题/边框上。
我尝试RibbonWindow
从课堂上提取,但我总是遇到麻烦。我就是做不到...
有人可以帮我吗?
我基本上需要将窗口的客户区扩展到整个窗口。
我需要将客户区扩展到框架中,而不是将框架扩展到客户区!
问问题
788 次
2 回答
2
自定义镶边功能允许应用程序控制窗口的外框,以便可以在标题栏上绘制 WPF 内容。
这听起来像你在找什么:WPF Shell Integration Library
于 2011-06-12T21:32:46.357 回答
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;
}
}
正如您所注意到的,您必须自己处理许多窗口行为,例如活动状态和位置更改,这很容易变得有点混乱。
于 2011-06-12T21:57:14.923 回答