[英]Frame Navigation UWP
嘿,我想做一些类似幻灯片的东西,你可以在其中启动应用程序,它会遍历页面,但程序不会加载。
public MainPage()
{
this.InitializeComponent();
while (true)
{
this.contentFrame.Navigate(typeof(Page1));
Thread.Sleep(10000);
this.contentFrame.Navigate(typeof(werbungPage));
Thread.Sleep(10000);
this.contentFrame.Navigate(typeof(ChartZielPage));
Thread.Sleep(10000);
this.contentFrame.Navigate(typeof(mitarbeiteronlinePage));
Thread.Sleep(10000);
this.contentFrame.Navigate(typeof(MomentaneKundenPage));
Thread.Sleep(10000);
this.contentFrame.Navigate(typeof(OutlookKalenderPage));
Thread.Sleep(10000);
this.contentFrame.Navigate(typeof(ChartServerPage));
Thread.Sleep(10000);
this.contentFrame.Navigate(typeof(ChartWheaterPage));
Thread.Sleep(10000);
}
}
嘿,我想做一些类似幻灯片的东西,你可以在其中启动应用程序,它会遍历页面,但程序不会加载。
问题是Thread.Sleep
使 UI 线程死锁,根据您的要求,我们建议使用DispathcerTimer
来处理幻灯片导航。
private int index;
private List<Type> pages = new List<Type>() { typeof(TestPage), typeof(BlankPage), typeof(BlankPage) };
public MainPage()
{
this.InitializeComponent();
var timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(2);
timer.Tick += Timer_Tick;
timer.Start();
}
private void Timer_Tick(object sender, object e)
{
if (index == pages.Count)
{
index = 0;
}
this.contentFrame.Navigate(pages[index]);
index++;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.