我已经整理了一个基本动画,其控制比例从0.1到1.0(x& y)。我一直看到的问题是,在他们确定最终静态之前,所述控件的“模糊”。
示例是我拍摄的这个屏幕。
我不确定是什么原因造成的。它是您通过Blend生成的默认动画/故事板。
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="UIBorder" >
<EasingDoubleKeyFrame KeyTime="0" Value="0.2">
<EasingDoubleKeyFrame.EasingFunction>
<BackEase EasingMode="EaseInOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame KeyTime="0:0:1.4" Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<BackEase EasingMode="EaseInOut" Amplitude="3"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
上述控制:
<Grid x:Name="UIBorder" Width="555" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<CompositeTransform ScaleY="0.2" ScaleX="0.2"/>
</Grid.RenderTransform>
<Grid Margin="122,0,0,0" RenderTransformOrigin="0.5,0.5" >
<Border Background="#FF343434" ManipulationMode="None" IsDoubleTapEnabled="False" IsHoldingEnabled="False" IsRightTapEnabled="False" IsTapEnabled="False" RenderTransformOrigin="0.5,0.5" >
<Border.RenderTransform>
<CompositeTransform/>
</Border.RenderTransform>
</Border>
</Grid>
<Image HorizontalAlignment="Left" VerticalAlignment="Center" Source="ms-appx:///Assets/Chrome/LoginSeal.png" Stretch="None"/>
</Grid>
注意:
答案 0 :(得分:6)
好像是一个错误。显然,WinRT在动画期间自动将CacheMode转换为BitmapCache,并以低比例缓存对象。虽然我无法重现您现在看到的内容,但在为TextBlocks的投影属性设置动画时,我在Windows 8的一个预发布版本中遇到了类似的问题。我认为可能发生的是它使用在开始动画之前使用的最大控件大小来确定用于BitmapCache的RenderAtScale属性值(在WinRT中不可用,但在Silverlight或WPF中存在,它看起来像是它的一个版本存在于WinRT中,它不会暴露给API的用户)。然后,一种解决方法可能是以某种方式无形地将位图的ScaleX / ScaleY值在加载时设置为1,然后在位图首次显示之前返回到0.2。或者,您可以将控件的不透明度设置为0并在动画开始之前缩放为1,然后在将比例设置为0.2后将淡入淡出控件。如果你真的需要在动画之前显示小的一个 - 你可以有两个控件副本 - 一个小动画在动画开始后消失,另一个小动画开始大而不可见(或者在Opacity =“0.005”并且非常快速地动画到不透明度1,动画开始时缩放0.2。
这对我来说很好看:
<Page
x:Class="App76.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App76"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<Storyboard
x:Name="anim"
SpeedRatio="0.2">
<DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)"
Storyboard.TargetName="UIBorder">
<EasingDoubleKeyFrame
KeyTime="0"
Value="0.2">
<EasingDoubleKeyFrame.EasingFunction>
<BackEase
EasingMode="EaseInOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame
KeyTime="0:0:1.4"
Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<BackEase
EasingMode="EaseInOut"
Amplitude="3" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)"
Storyboard.TargetName="UIBorder">
<EasingDoubleKeyFrame
KeyTime="0"
Value="0.2">
<EasingDoubleKeyFrame.EasingFunction>
<BackEase
EasingMode="EaseInOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame
KeyTime="0:0:1.4"
Value="1">
<EasingDoubleKeyFrame.EasingFunction>
<BackEase
EasingMode="EaseInOut"
Amplitude="3" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
<Grid
Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid
x:Name="UIBorder"
Width="555"
HorizontalAlignment="Center"
VerticalAlignment="Center"
RenderTransformOrigin="0.5,0.5">
<!--<Grid.CacheMode>
<BitmapCache
/>
</Grid.CacheMode>-->
<Grid.RenderTransform>
<CompositeTransform
x:Name="ct"
ScaleY="0.2"
ScaleX="0.2" />
</Grid.RenderTransform>
<Grid
Margin="122,0,0,0"
RenderTransformOrigin="0.5,0.5">
<Border
Background="#FF343434"
ManipulationMode="None"
IsDoubleTapEnabled="False"
IsHoldingEnabled="False"
IsRightTapEnabled="False"
IsTapEnabled="False"
RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<CompositeTransform />
</Border.RenderTransform>
</Border>
</Grid>
<Image
HorizontalAlignment="Left"
VerticalAlignment="Center"
Source="ms-appx:///Assets/SplashScreen.png"
Stretch="None" />
</Grid>
<Button
VerticalAlignment="Bottom"
HorizontalAlignment="Left"
Content="TEST"
Click="ButtonBase_OnClick" />
</Grid>
</Page>
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace App76
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
ct.ScaleX = 1;
ct.ScaleY = 1;
this.Loaded += MainPage_Loaded;
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
ct.ScaleX = 0.2;
ct.ScaleY = 0.2;
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
anim.Begin();
}
}
}
答案 1 :(得分:1)
为UIBorder设置UseLayoutRounding =“True”