In WPF XAML there is the convenient DesignHeight and DesignWidth, for instance in code as
DesignHeight
DesignWidth
My answer was found here: Black Background for XAML Editor. There are a number of choices including checking System.ComponentModel.DesignerProperties.GetIsInDesignMode(this) at runtime.
System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)