Reputation: 67
Hey I want to make something like a slide show, where you start the application and it goes through pages but the program don't load.
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);
}
}
Upvotes: 0
Views: 118
Reputation: 32785
Hey I want to make something like a slide show, where you start the application and it goes through pages but the program don't load.
The problem is Thread.Sleep
make UI-thread deadlock, for your requirement, we suggest use DispathcerTimer
to process the slide navigation.
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++;
}
Upvotes: 1