开发者

How to get VisualStateGroup properties from a UserControl to reference in the ViewModel in Silverlight 4 C# code?

I'm trying to make visual states available in the ViewModel as some sort of enumeration (so that I don't have to use string literals or manually create and update static properties in order to be able to control states), and I accidentally found out that Silverlight actually generates internal VisualStateGroup properties in the g.i.cs classes which I could perhaps use.

So my question is what would be the best way to expose these VisualStateGroups and the actual visual states in them as static getters? Extending UserControl could wor开发者_如何学Ck perhaps, but if possible I'd prefer do be able to do it on demand with an AttachedProperty, any ideas about the pros / cons or even workability of these approaches?

Thanks in advance!


I support this in Jounce (http://jounce.codeplex.com/) and you can view the source. Also take a look here where I describe how to iterate the visual state manager and hook into various events and iterate the states and transitions:

http://csharperimage.jeremylikness.com/2011/01/visual-state-manager-explained.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜