这可以实现吗?
是的,我已经上传了一个完整的演示以满足您的要求。您可以下载CSplashScreen 解决方案进行测试。
为了满足您的要求,
制作一个显示不同图片的动画。
我用一个 FlipView 控件和一个DispatcherTimer 来实现它。所以闪屏可以自动一张一张的显示图片。
Splash 占据所有屏幕尺寸(适用于不同的屏幕尺寸)
FlipView 始终适合窗口的大小,并且图像在不同设备中显示为全窗口。
Xaml 代码:
<FlipView x:Name="ImageFlipView">
<Image Source="ms-appx:///Assets/caffe600320.jpg" Stretch="Fill" />
<Image Source="ms-appx:///Assets/cafee2.jpg" Stretch="Fill" />
<Image Source="ms-appx:///Assets/caffe3.jpg" Stretch="Fill" />
</FlipView>
后面的代码:
private SplashScreen splash; // Variable to hold the splash screen object
internal bool dismissed = false; // Variable to track splash screen dismi
internal Frame rootFrame;
private readonly DispatcherTimer _timer;
public ExtendedSplash(SplashScreen splashscreen, bool loadState)
{
this.InitializeComponent();
StatusBar statusbar = StatusBar.GetForCurrentView();
statusbar.HideAsync();
if (splash != null)
{
splash.Dismissed += new TypedEventHandler<SplashScreen, Object>(D
}
rootFrame = new Frame();
_timer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(2)
};
_timer.Tick += ChangeImage;
_timer.Start();
}
private void ChangeImage(object sender, object e)
{
var totalItems = ImageFlipView.Items.Count;
var newItemIndex = (ImageFlipView.SelectedIndex + 1) % totalItems;
ImageFlipView.SelectedIndex = newItemIndex;
}
void DismissedEventHandler(SplashScreen sender, object e)
{
dismissed = true;
}
UWP 设计指南中是否允许这样做?
来自官方文档Display a splash screen for more time,
遵循以下建议,确保您的扩展启动画面准确地模仿默认启动画面:
该文档提供了有关创建您自己的扩展初始屏幕的建议。最佳做法是遵循建议。启动画面的指南也建议我们:
- 不要使用初始屏幕或扩展的初始屏幕来显示广告。
- 不要将扩展的初始屏幕用作显示多个不同初始屏幕图像的机制。启动画面和扩展启动画面的目的是为您的用户提供流畅、优美的加载体验。
- 不要使用初始屏幕或扩展的初始屏幕来显示“关于”页面。