Tuesday, December 11, 2012

Detect Windows Phone Application In Edit Mode

Sometimes we have to know when your code is running in the editor.

When authoring a control, it's common to include code that must run outside the editor, otherwise it would cause an exception in edit mode.

The following code shows how to do it:
public partial class YourControl: UserControl
{
    public YourControl()
    {
        InitializeComponent();

        if (!DesignerProperties.IsInDesignTool)
        {
            //code to run outside the editor
        }
    }
}

No comments:

Post a Comment