Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Assists/WindowAssist.cs
ShrlAlgo 955a01f564 整理
2025-08-20 12:10:35 +08:00

34 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace NeoUI.Assists;
/// <summary>
/// WindowAssist 类提供了对窗口控件的辅助功能,特别是针对自定义标题栏背景颜色的支持。通过此类可以方便地设置和获取与窗口关联的标题栏背景画刷。
/// </summary>
public class WindowAssist
{
/// <summary>
/// 获取指定依赖对象的标题栏背景画刷。
/// </summary>
/// <param name="obj">要获取其标题栏背景画刷的依赖对象。</param>
/// <returns>与指定依赖对象关联的标题栏背景画刷。</returns>
public static Brush GetTitleBarBackground(DependencyObject obj)
{
return (Brush)obj.GetValue(TitleBarBackgroundProperty);
}
/// <summary>
/// 设置指定依赖对象的标题栏背景画刷。
/// </summary>
/// <param name="obj">要设置标题栏背景的依赖对象。</param>
/// <param name="value">作为标题栏背景的新画刷值。</param>
public static void SetTitleBarBackground(DependencyObject obj, Brush value)
{
obj.SetValue(TitleBarBackgroundProperty, value);
}
/// <summary>
/// 用于定义依赖属性的标识符该属性允许设置和获取与窗口控件关联的标题栏背景画刷。此属性可以应用于任何实现了DependencyObject接口的对象上以便自定义其标题栏背景颜色。
/// </summary>
public static readonly DependencyProperty TitleBarBackgroundProperty =
DependencyProperty.RegisterAttached("TitleBarBackground", typeof(Brush), typeof(WindowAssist));
}