在wince中使用C++语言创建Silverlight的VisualState
2010-08-23 05:29:00 来源:WEB开发网< TransformGroup>
< ScaleTransform/>
< SkewTransform/>
< RotateTransform/>
< TranslateTransform/>
< /TransformGroup>
< /Rectangle.RenderTransform>
< /Rectangle>
< /Grid>
< /UserControl>
下面,一层层分析,使用本地代码来实现等效的功能:
首先,创建一个IXRVisualStateGroupCollection(即状态组的集合),并与Grid进行绑定
IXRVisualStateGroupCollection* pVisualStateGroups;
app->CreateObject(IID_IXRVisualStateGroupCollection, &pVisualStateGroups);
LayoutRoot->SetAttachedProperty(L"VisualStateManager.VisualStateGroups", pVisualStateGroups);
创建一个状态组,并将其添加到状态组集合中
IXRVisualStateGroupPtr pGroup;
app->CreateObject(IID_IXRVisualStateGroup,&pGroup);
pGroup->SetName(L"VisualStateGroup");
pVisualStateGroups->Add(pGroup,NULL);
通过状态组下的IXRVisualTransitionCollection来设置通用的切换时间,现在暂定为1秒
IXRVisualTransitionCollectionPtr transitions;
app->CreateObject(IID_IXRVisualTransitionCollection,&transitions);
pGroup->SetTransitions(transitions);
IXRVisualTransitionPtr transtion;
app->CreateObject(IID_IXRVisualTransition,&transtion);
XRDuration duration;
duration.DurationType = duration.DurationType_TimeSpan;
duration.TimeSpan.Ticks = duration.TimeSpan.TicksPerSecond;
transtion->SetGeneratedDuration(&duration);
transitions->Add(transtion,NULL);
创建状态集合,并将新建的状态添加进去
IXRVisualStateCollectionPtr StateCollection;
pGroup->GetStates(&StateCollection);
IXRVisualStatePtr state;
app->CreateObject(IID_IXRVisualState,&state);
更多精彩
赞助商链接