Xaml datatemplate Windows 8.1中的情节提要
是否可以从datatemplate中的代码隐藏(.cs文件)开始故事板。下面的代码不工作,请通知我Xaml datatemplate Windows 8.1中的情节提要,xaml,windows-phone-8,windows-8,windows-8.1,Xaml,Windows Phone 8,Windows 8,Windows 8.1,是否可以从datatemplate中的代码隐藏(.cs文件)开始故事板。下面的代码不工作,请通知我 <HubSection Width="800" x:Name="Section2" Header="Section 2" Foreground="Black"> <DataTemplate x:Name="DataTemplateNotificaiton" > <Grid Background="White" Width="7
<HubSection Width="800" x:Name="Section2" Header="Section 2" Foreground="Black">
<DataTemplate x:Name="DataTemplateNotificaiton" >
<Grid Background="White" Width="700" Height="500" Margin="-20" >
<Canvas x:Name="canvas" Margin="0,302,0,-302" Canvas.ZIndex="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" >
<Canvas.Resources>
<Storyboard x:Name="TileAnimation">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="canvas">
<EasingDoubleKeyFrame KeyTime="0" Value="-1.5"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="-252"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Canvas.Resources>
<Canvas.RenderTransform>
<CompositeTransform/>
</Canvas.RenderTransform>
<TextBlock x:Name="panel1" Margin="30,30,0,0" Text="sdasdasdasd" FontFamily="Segoe WP Light" FontSize="32" >
<TextBlock.RenderTransform>
<TranslateTransform/>
</TextBlock.RenderTransform>
</TextBlock>
<TextBlock x:Name="panel2" Margin="30,7,0,0" TextWrapping="Wrap" Text="adasdasdasdasd" FontFamily="Segoe WP Light" FontSize="22" Canvas.Top="98">
<TextBlock.RenderTransform>
<TranslateTransform/>
</TextBlock.RenderTransform>
</TextBlock>
</Canvas>
</Grid>
</DataTemplate>
</HubSection>
是的,但是很复杂,不推荐,当您想保持代码可读性时。 我的建议是,开发一个userControl,其中包含模板中当前的所有内容,然后在该控件中设计动画。 您可以轻松地在datatemplate中添加此新控件,而不是上面的代码。这也使得测试控件更容易
HTH Oliver是的,Oliver,如果我这样做,脚本将在usercontrol中返回null。您将此代码称为何处?就在构造器里?还是稍后在加载的事件中?
Storyboard anim = (Storyboard)FindName("TileAnimation");
anim.Begin();