Using the SystemColors class and specifically the WindowColor property. When using xaml it is better to use DynamicResources and therefore use the ...Key properties. That way your application changes in the fly when the user changes the color in Windows.
<Window>
<Window.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.WindowColorKey}}">
</SolidColorBrush>
</Window.Background>
</Window>
Using the ...BrushKey properties makes it easier to use when in need of a brush
<Window Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
</Window>
PS: WPF Windows should already have the correct color by default