Posted by: MarkWPF
Controls, WPF, XAML
Have you ever written any user controls or custom controls?
The difference between them is that with a custom control you have full scope to render it (plus you have to do it), whereas a user control is a container to amalgamate other controls.
With both of them though, you need to make sure that any calls made out of them are minimised.
Well because when they are created in WPF designers like Visual Studio 2008 or Expression Blend, they will be instantiated and therefore constructors will be called.
If you have calls out to databases etc, you will get a nasty looking exception thrown, or just the Visual Studio 2008 problem loading display:
How do you sort this problem?
By using the GetIsInDesignMode static method of DesignerProperties, like so
// do something you don’t want to appear in designer