How do I programmatically get the current Visual State of a WPF FrameworkElement?

自闭症网瘾萝莉.ら 提交于 2019-12-04 01:56:47

I think you have to know/remember the button state by yourself. VSM just displays the state in which the button is by GoToState method.

Edit: I've just found an article how to create a custom VSM that remembers control states.

I feel you've missed the point of WPF here, it's the View not the Model. You should not be storing state in the View. Store state in your Model(s) and use the View to represent it. On that basis you don't need to read the state of the View, you already know it.

I know this may seem like a lot of work at the moment but it'll pay you back in spades later.

Haritha

I think you should use GoToElementState method instead of GoToState method.

VisualStateManager.GoToElementState(LayoutRoot, "Add", true);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!