Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have Window 8.1 Application code. It is using MVVM design to manage files in ViewModel and model.

But at each ViewModel class it is using below if block. i am not able to understand what is the purpose of using this block.

C#
if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
{
 
}

I also gone through with http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.designmode.designmodeenabled.aspx[^]. How we can use this in our program is not described here.

Can someone help me to understand this ?

Thanks
Posted

1 solution

The description you link to is pretty clear:
True if the process is running in design mode; otherwise false.
Remarks

Use the DesignModeEnabled property when your custom types require special logic when running in a visual designer.


I.e. it allows your code to determine if it is running in the Visual Studio designer or on a live form.
If it's on a designer, you might want to fill it with dummy data, or put a border round it, or anything else to make the designers job easier, but that won't affect the "Live" form.
 
Share this answer
 
Comments
girishmeena 10-Mar-14 7:10am    
Thanks, That's make sense to me. but what i need to do so that it will run under DesignModeEnabled = true.
Right now i am debugging the code in VS 2013 in my local machine but it always return DesignModeEnabled = false.
OriginalGriff 10-Mar-14 7:20am    
That's because it's under the debugger - which means it's running code. That's not in the designer any more, it's in a live form!
girishmeena 10-Mar-14 11:39am    
Ok. when it will go to DesignModeEnabled = true ?
OriginalGriff 10-Mar-14 11:52am    
When it's running in the designer!
I.e. when you drop an instance of your control onto the Visual Studio Form in Design view.
See here: http://msdn.microsoft.com/en-us/library/5ytx0z24(v=vs.90).aspx
It describes how to design-time debug a control.
girishmeena 11-Mar-14 0:25am    
Thanks You very much Griff. And Thanks again for giving many answers in a single question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900