I have a WPF form which basically looks like this:
[content shown during normal operation]
Since there is no built-in way to do this, I decided to implement a solution myself, which was surprisingly easy to do using attached properties:
Public Class DesignModeTool
Public Shared ReadOnly IsHiddenProperty As DependencyProperty = DependencyProperty.RegisterAttached( _
"IsHidden", GetType(Boolean), GetType(DesignModeTool), _
New FrameworkPropertyMetadata(False, New PropertyChangedCallback(AddressOf OnIsHiddenChanged)))
Public Shared Sub SetIsHidden(ByVal element As UIElement, ByVal value As Boolean)
element.SetValue(IsHiddenProperty, value)
End Sub
Public Shared Function GetIsHidden(ByVal element As UIElement) As Boolean
Return DirectCast(element.GetValue(IsHiddenProperty), Boolean)
End Function
Private Shared Sub OnIsHiddenChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
If System.ComponentModel.DesignerProperties.GetIsInDesignMode(d) AndAlso True.Equals(e.NewValue) Then
With DirectCast(d, FrameworkElement)
.Width = 0
.Height = 0
End With
End If
End Sub
End Class
After declaring a namespace, the feature can be used like this:
[stuff I don't want to be shown in the designer]