Represents a set of caption buttons (close, minimize, maximize, fullscreen) for a PleasantWindow. Automatically handles window state changes and button visibility based on window configuration.
The caption buttons are typically used within a PleasantTitleBar template and are automatically wired to the host window:
<chrome:PleasantCaptionButtons Host="{Binding RelativeSource={RelativeSource AncestorType=chrome:PleasantWindow}}" />| Property | Type | Description |
|---|---|---|
Host |
PleasantWindow? |
The host window for these caption buttons |
The Type enum (defined on PleasantWindow) controls which buttons are visible:
All- All buttons are visible (Close, Minimize, Maximize)CloseAndCollapse- Close and Minimize buttons are visibleCloseAndExpand- Close and Maximize buttons are visibleClose- Only the Close button is visibleNone- No buttons are visible
Set on the host window:
window.CaptionButtons = PleasantCaptionButtons.Type.CloseAndCollapse;- Windows: Shows standard close, minimize, maximize buttons
- macOS: The maximize button toggles fullscreen mode instead of maximize/restore
- Fullscreen mode: In fullscreen, only Close and FullScreen buttons are shown
The control applies pseudo-classes based on window state:
:minimized- Applied when window is minimized:normal- Applied when window is in normal state:maximized- Applied when window is maximized:fullscreen- Applied when window is in fullscreen mode:isactive- Applied when window is inactive
Use these for styling:
<Style Selector="chrome:PleasantCaptionButtons:minimized">
<Setter Property="Opacity" Value="0.5" />
</Style>When the title bar is removed or the window is destroyed, call Detach() to clean up subscriptions:
captionButtons.Detach();The control template must provide:
PART_CloseButton- Close buttonPART_MaximizeButton- Maximize/Restore buttonPART_MinimizeButton- Minimize buttonPART_FullScreenButton- Fullscreen toggle button (optional)
- Button visibility is automatically updated based on window properties like
CanResize,CanMinimize, and individual button visibility properties - The control automatically subscribes to window state changes and updates pseudo-classes