1

Is there a way to set the visual state of a control during design time in Miscrosoft Blend ?

(For example setting the state of a TextBox to "Disabled" so that one can see the disabled TextBox on the design surface)

Thanks in advance :)

marc wellman
  • 5,808
  • 5
  • 32
  • 59

2 Answers2

2

What I usaly does, using MVVM, is to bind the state I wish to control to a propertie in my ViewModel. I use MVVMLight as my MVVM framework, there you got a "IsInDesignMode" propertie which you can check agains, and set your desired design time properties.

Hope this helps.

AndreasW
  • 106
  • 3
1

Right click your TextBox and choose "Edit Template" -> "Edit A Copy" and break the template out into a resource dictionary or wherever you like, generally a new resource dictionary is a good place. This will take you to the template for that control, then click the "States" tab (Normally top left corner in blend) and it will reveal the various states of your control including disabled and expose the objects that create your control.

All this stuff is also of course found in your VisualStateManager code, but looking at the states in the template is the easiest route with visual interpretations of the states viewable as you click them. As you click around the states notice the little red dots that appear on your objects in your objects & timeline panel to see what elements are being interacted with per that state. Makes things much easier. Hope this helps, if not define further and we'll get ya set up right. Cheers Marc. :)

Chris W.
  • 22,835
  • 3
  • 60
  • 94
  • Oh ya, and if you're just trying to see what the disabled state looks like while its up without going through the trouble, just add IsEnabled="False" to the xaml.... thought I'd add that. – Chris W. Jan 06 '12 at 22:21
  • Hey Chris :) Seems that you are my personal answering-agent this time :) Regarding the question: I've already defined the visual state of my control inside its control template (with the VSM). Everything works quite well - i can build as many states I want. But when i leave the VSM returning to my ordinary design surface I will only see my controls in their "base" state (not their "normal" one). Now what I actually want is to see them in their "Disabled" state while beeing in the standard design surface of Blend. Do you now what I mean ? If not I will reformulate again ;) so long, ... – marc wellman Jan 06 '12 at 22:31
  • Another way to formulate my issue is: How can set an initial state for a control in which it should be loaded on startup ? – marc wellman Jan 06 '12 at 23:37
  • Well if you just want to have them in disabled state when its loaded, just do like – Chris W. Jan 07 '12 at 19:29