Aligning custom buttons perfectly with the default caption buttons using only the HeaderTemplate can be quite limiting. The HeaderTemplate is primarily intended for defining the header content, not for integrating with the native window caption controls.
To achieve precise alignment and behavior similar to default caption buttons, it is recommended to customize the style of the floating window itself. Specifically, it can be modified the - FloatWindowStyle by accessing the NativeWindowStyle property of the DockingManager.
In the attached sample, a custom Refresh button was added directly into the header style and bound it to the ContentControl within the NativeFloatWindow template. This approach ensures the custom button aligns seamlessly with the default window controls and behaves consistently. Attached are the sample project and demo video for reference.