Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you check for ONLY the Visual Studio 2010 designer (so that Blend's designer is NOT targeted) in WPF?
    primarykey
    data
    text
    <p>I've found that in many cases the designer in Visual Studio 2010 or in Expression Blend 4 will crash if, for example, a WPF UserControl contains a control does something in code based on the control's loaded event (like transition to a different Visual State via a call like <code>VisualStateManager.GoToState(this, "AfterLoaded", true);</code>). </p> <p>My typical approach to solving these designer crashes is use the <a href="https://stackoverflow.com/a/834332/718325"><code>DesignerProperties.GetIsInDesignMode(this)</code> approach</a> in the control's contructor:</p> <pre><code>public MyControl() { // prevent designer crashes if (DesignerProperties.GetIsInDesignMode(this)) return; Loaded += MyControlLoaded; Unloaded += MyControlUnloaded; IsVisibleChanged += MyControlIsVisibleChanged; } </code></pre> <p>This approach targets both Visual Studio 2010 and Expression Blend 4 and enables me to have my design surface visible again. However, it also removes any design-time preview that a designer might provide for me (like with the above-mentioned VSM state change on the loaded event). Blend, in particular, is able to provide that preview for me in its designer (if I switch to a different Blend tab and then switch back to the original tab I see the loaded animation run). Furthermore, with some controls that I have not yet applied the above approach to, Visual Studio 2010's designer will crash, while Blend 4's designer will not. Thus what I would like to do is check for <strong>only</strong> Visual Studio 2010's designer so that I can let Blend's designer pass through and provide its previewing abilities.</p> <p>The benefit of this ability would be that I save time by not needing to build and run the application as often (to see things like the loaded animation) since Blend's designer could give me its preview. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload