3.9 KiB
3.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
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 callsInitializeComponent()and attaches anIsEnabledChangedhandler to callRefreshContent().Content(DependencyProperty) - The button content when enabled. Hides baseButton.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()- SetsActiveContenttoContentif enabled, otherwiseContentDisabled.BackgroundDefaultValue(virtual property) - ReturnsDefaultBackgroundBrushfrom resources.
WindowMaximizeButton : WindowButton
WindowMaximizeButton()- LoadsWindowButtonMaximizeIconandWindowButtonMaximizeIconDisabledfromButtonIcons.xaml.
WindowRestoreButton : WindowButton
WindowRestoreButton()- LoadsWindowButtonRestoreIconandWindowButtonRestoreIconDisabledfromButtonIcons.xaml.
WindowCloseButton : WindowButton
WindowCloseButton()- LoadsWindowButtonCloseIconandWindowButtonCloseIconDisabledfromButtonIcons.xaml.
WindowMinimizeButton : WindowButton
WindowMinimizeButton()- LoadsWindowButtonMinimizeIconandWindowButtonMinimizeIconDisabledfromButtonIcons.xaml.
WindowButtonState (enum)
- Values:
Normal,Disabled,None
TypeConverterStringToUIElement : TypeConverter
CanConvertFrom(ITypeDescriptorContext, Type)- Returnstrueif source type isstring.ConvertFrom(ITypeDescriptorContext, CultureInfo, object)- Converts string to aTextBlockwith vertical centering and left margin of 3.
Invariants
ButtonIcons.xamlmust exist in the assembly at the pack URIpack://application:,,,/CustomWindow;component/ButtonIcons.xaml.- The resource dictionary must contain the icon keys:
WindowButtonMaximizeIcon,WindowButtonMaximizeIconDisabled,WindowButtonRestoreIcon,WindowButtonRestoreIconDisabled,WindowButtonCloseIcon,WindowButtonCloseIconDisabled,WindowButtonMinimizeIcon,WindowButtonMinimizeIconDisabled. DefaultBackgroundBrushmust be defined in resources forBackgroundDefaultValueto 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.xamlviaXamlReader.Load()at instantiation time. This has performance implications if many buttons are created. - No error handling: The resource loading will throw if
ButtonIcons.xamlis missing or if expected resource keys are absent. - Shadowed Content property: The
newkeyword hides the baseButton.Contentproperty. SettingContenton aWindowButtonwill not behave like a standard button. - Commented-out code:
WindowCloseButtonandWindowMinimizeButtoncontain commented-outCornerRadiusassignments, suggesting incomplete refactoring.