Windows store apps windows应用商店应用程序c中的图像淡入淡出
我正在用c编写Windows8应用商店应用程序。我需要在应用程序中实现图像淡入淡出 我试着在它上面加上边框并增加厚度,但没有成功 有谁能帮我实施吗Windows store apps windows应用商店应用程序c中的图像淡入淡出,windows-store-apps,Windows Store Apps,我正在用c编写Windows8应用商店应用程序。我需要在应用程序中实现图像淡入淡出 我试着在它上面加上边框并增加厚度,但没有成功 有谁能帮我实施吗 谢谢通过使用视觉状态管理器,您可以实现图像淡入动画。我没有尝试过这段代码,如果你发现任何错误,请告诉我: <Button x:Name="btnFade" Content="Fade" Click="Button_Click" /> <Image x:Name="imageControl" width="500" height="5
谢谢通过使用视觉状态管理器,您可以实现图像淡入动画。我没有尝试过这段代码,如果你发现任何错误,请告诉我:
<Button x:Name="btnFade" Content="Fade" Click="Button_Click" />
<Image x:Name="imageControl" width="500" height="500" Source="ms-appx:///dummy.jpg" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup >
<VisualState x:Name="FadeInState">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="imageControl"
Storyboard.TargetProperty="Opacity"
From="1.0" To="0.5" Duration="0:0:5"
/>
</Storyboard>
</VisualState>
<VisualState x:Name="FadeOutState">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="imageControl"
Storyboard.TargetProperty="Opacity"
From="0.5" To="1.0" Duration="0:0:5"
/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
// code behind
private bool isFadeIn = false;
private async void Button_Click(object sender, RoutedEventArgs e)
{
if(isFadeIn == true)
VisualStateManager.GoToState(gridControl, "FadeInState", true);
else
VisualStateManager.GoToState(gridControl, "FadeOutState", true);
isFadeIn != isFadeIn;
}
这就是你要找的吗?