Reputation: 815
I have a problem with CarouselPage. When initializing, I assign CarouselPage.ItemSource = .... At start i need to show second page, not first.
My code:
Weeks = new ObservableCollection<Week>
{
new Week {Days = GetDays(currentMonday.AddDays(-7)), ItemTappedCommand = JobTappedCommand},
new Week {Days = GetDays(currentMonday), ItemTappedCommand = JobTappedCommand},
new Week {Days = GetDays(currentMonday.AddDays(7)), ItemTappedCommand = JobTappedCommand},
};
CurrentDate = Weeks[1].DateOfFirstDayOfWeek;
How can I do this?
Upvotes: 0
Views: 447
Reputation: 815
I make this:
private bool _isInitialized;
private void CarouselAllJobsWeekPage_OnPagesChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (!_isInitialized
&& Children.Count > 2)
{
CurrentPage = this.Children[1];
_isInitialized = true;
}
}
Upvotes: 0
Reputation: 5768
I think (but I have not test) you can use something like
this.CurrentPage = this.Children[1];
Upvotes: 0