protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var settings = new Models.Domain.FolderItemListing.FolderListingSettings(); if (settings.IsForceEnableXYNavigation || Xamarin.Essentials.DeviceInfo.Idiom == Xamarin.Essentials.DeviceIdiom.TV ) { if (FoldersAdaptiveGridView.Items.Any()) { var firstItem = FoldersAdaptiveGridView.Items.First(); var itemContainer = FoldersAdaptiveGridView.ContainerFromItem(firstItem) as Control; itemContainer.Focus(FocusState.Keyboard); } else if (FileItemsRepeater_Small.ItemsSource != null && FileItemsRepeater_Small.Visibility == Visibility.Visible) { var item = FileItemsRepeater_Small.FindDescendant <Control>(); item?.Focus(FocusState.Keyboard); } else if (FileItemsRepeater_Midium.ItemsSource != null && FileItemsRepeater_Midium.Visibility == Visibility.Visible) { var item = FileItemsRepeater_Midium.FindDescendant <Control>(); item?.Focus(FocusState.Keyboard); } else if (FileItemsRepeater_Large.ItemsSource != null && FileItemsRepeater_Large.Visibility == Visibility.Visible) { var item = FileItemsRepeater_Large.FindDescendant <Control>(); item?.Focus(FocusState.Keyboard); } else { ReturnSourceFolderPageButton.Focus(FocusState.Keyboard); this.FoldersAdaptiveGridView.ContainerContentChanging -= FoldersAdaptiveGridView_ContainerContentChanging; this.FileItemsRepeater_Small.ElementPrepared -= FileItemsRepeater_Large_ElementPrepared; this.FileItemsRepeater_Midium.ElementPrepared -= FileItemsRepeater_Large_ElementPrepared; this.FileItemsRepeater_Large.ElementPrepared -= FileItemsRepeater_Large_ElementPrepared; this.FoldersAdaptiveGridView.ContainerContentChanging += FoldersAdaptiveGridView_ContainerContentChanging; this.FileItemsRepeater_Small.ElementPrepared += FileItemsRepeater_Large_ElementPrepared; this.FileItemsRepeater_Midium.ElementPrepared += FileItemsRepeater_Large_ElementPrepared; this.FileItemsRepeater_Large.ElementPrepared += FileItemsRepeater_Large_ElementPrepared; } } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await Task.Delay(500); var settings = new Models.Domain.FolderItemListing.FolderListingSettings(); if (settings.IsForceEnableXYNavigation || Xamarin.Essentials.DeviceInfo.Idiom == Xamarin.Essentials.DeviceIdiom.TV ) { if (FoldersAdaptiveGridView.Items.Any()) { var firstItem = FoldersAdaptiveGridView.Items.First(); var itemContainer = FoldersAdaptiveGridView.ContainerFromItem(firstItem) as Control; if (itemContainer != null) { itemContainer.Focus(FocusState.Keyboard); } } } }