silverlight中的VisualState(可视状态)是一个非常重要的概念,使用VisualState,可以将界面的各个状态进行有效的区隔开,并进行单独的设计,并且在状态切换间可以通过设置切换时间来实现动画效果,一般来说,可以通过blend2(微软提供的可视化编程工具)进行设计,但是如果需要动态读取数值并进行设置的话,就需要使用本地的C++代码来编写各个VisualState,下面通过示例展示如何通过编写C++代码来实现与xaml代码同样的功能。
如下所示,xaml文件创建了一个状态,并在该状态下,将矩形旋转了75度。
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SilverlightApplication30.Page"
Width="640" Height="480" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" x:Name="Root">
<Grid x:Name="LayoutRoot" Background="White">
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="VisualStateGroup">
<vsm:VisualStateGroup.Transitions>
<vsm:Visua