Files
DP44/docs/ai/DataPRO/CustomWindow.md
2026-04-17 14:55:32 -04:00

3.9 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/CustomWindow/WindowMaximizeButton.cs
DataPRO/CustomWindow/WindowRestoreButton.cs
DataPRO/CustomWindow/WindowCloseButton.cs
DataPRO/CustomWindow/WindowMinimizeButton.cs
DataPRO/CustomWindow/Others.cs
DataPRO/CustomWindow/WindowButton.xaml.cs
2026-04-17T16:28:39.453177+00:00 zai-org/GLM-5-FP8 1 855cc573ec161a3c

CustomWindow

Purpose

This module provides custom window chrome controls for WPF applications, specifically styled window title bar buttons (minimize, maximize, restore, close). It implements a custom WindowButton base class with dependency properties for managing button content states and corner radius styling, enabling consistent custom window styling across the application.

Public Interface

WindowButton : Button

  • WindowButton() - Constructor that calls InitializeComponent() and attaches an IsEnabledChanged handler to call RefreshContent().
  • Content (DependencyProperty) - The button content when enabled. Hides base Button.Content.
  • ContentDisabled (DependencyProperty) - The button content when disabled.
  • CornerRadius (DependencyProperty) - Corner radius for button styling.
  • ActiveContent (DependencyProperty) - The currently active content based on enabled state.
  • RefreshContent() - Sets ActiveContent to Content if enabled, otherwise ContentDisabled.
  • BackgroundDefaultValue (virtual property) - Returns DefaultBackgroundBrush from resources.

WindowMaximizeButton : WindowButton

  • WindowMaximizeButton() - Loads WindowButtonMaximizeIcon and WindowButtonMaximizeIconDisabled from ButtonIcons.xaml.

WindowRestoreButton : WindowButton

  • WindowRestoreButton() - Loads WindowButtonRestoreIcon and WindowButtonRestoreIconDisabled from ButtonIcons.xaml.

WindowCloseButton : WindowButton

  • WindowCloseButton() - Loads WindowButtonCloseIcon and WindowButtonCloseIconDisabled from ButtonIcons.xaml.

WindowMinimizeButton : WindowButton

  • WindowMinimizeButton() - Loads WindowButtonMinimizeIcon and WindowButtonMinimizeIconDisabled from ButtonIcons.xaml.

WindowButtonState (enum)

  • Values: Normal, Disabled, None

TypeConverterStringToUIElement : TypeConverter

  • CanConvertFrom(ITypeDescriptorContext, Type) - Returns true if source type is string.
  • ConvertFrom(ITypeDescriptorContext, CultureInfo, object) - Converts string to a TextBlock with vertical centering and left margin of 3.

Invariants

  • ButtonIcons.xaml must exist in the assembly at the pack URI pack://application:,,,/CustomWindow;component/ButtonIcons.xaml.
  • The resource dictionary must contain the icon keys: WindowButtonMaximizeIcon, WindowButtonMaximizeIconDisabled, WindowButtonRestoreIcon, WindowButtonRestoreIconDisabled, WindowButtonCloseIcon, WindowButtonCloseIconDisabled, WindowButtonMinimizeIcon, WindowButtonMinimizeIconDisabled.
  • DefaultBackgroundBrush must be defined in resources for BackgroundDefaultValue to function.

Dependencies

  • Depends on: System.Windows, System.Windows.Controls, System.Windows.Markup, System.Windows.Media, System.ComponentModel.
  • Depended on by: Not determinable from source alone; likely used by custom window templates or shell views.

Gotchas

  • Runtime resource loading: Each button constructor loads ButtonIcons.xaml via XamlReader.Load() at instantiation time. This has performance implications if many buttons are created.
  • No error handling: The resource loading will throw if ButtonIcons.xaml is missing or if expected resource keys are absent.
  • Shadowed Content property: The new keyword hides the base Button.Content property. Setting Content on a WindowButton will not behave like a standard button.
  • Commented-out code: WindowCloseButton and WindowMinimizeButton contain commented-out CornerRadius assignments, suggesting incomplete refactoring.