我试图使用动画使用(对于一个windows 8手机应用程序)
VisualStateManager 但当我做的时候
VisualStateManager.GoToState结果是假的。我已经正确地定义了所有的州和网格。我在主网格布局下有一个名为"ContentPanel“的网格布局。在"ContentPanel“下,我有长方形,这个动画必须在其上工作。我使用代码后面的代码动态创建了所有这些矩形。我已经在相同的代码中创建了所有的状态和动画,并试图运行上面提到的行。
我搜索并找到了使用GoToElementState()方法的不同解决方案。但是,在我使用的类VisualStateManager类中没有看到这个方法。我知道这是一种静态的方法,但它并没有出现在建议中。
我还尝试使用ExtendedVisualStateManager类。就连这个都找不到。
最重要的是,我不知道为什么我的GoToState不工作。如果我有一个网格的主元素(如LayoutRoot),那么这个动画就可以工作了。我用了以下几行
VisualStateManager.GetVisualStateGroups(this.ContentPanel); // ContentPanel是布局的名称,其中有必须绑定动画的其他矩形。然后我用这个命令..。
VisualStateManager.GoToState(this, "stateName", true) // Returns false. Nothing happens when this is executed. Can any one please suggest me with the right implementation of this. 谢谢,
Sri Tej N.
发布于 2014-05-16 12:51:07
如果您的可视化状态位于Grid下,则
VisualStateManager.GoToState(this, "stateName", true)无法工作,因为this很可能是一个Page,它不直接包含Visual 。
和
VisualStateManager.GoToState(this.YourGrid, "stateName", true)也不能工作,因为GoToState的第一个参数需要是Control的一种类型-- Grid不能继承Control。
你需要用这个。
ExtendedVisualStateManager.GoToElementState(this.YourGrid, "stateName", true)https://stackoverflow.com/questions/22273502
复制相似问题