private void UpdateViewState()
        {
            ListDetailsViewState previousState = ViewState;

            if (_twoPaneView == null)
            {
                ViewState = ListDetailsViewState.Both;
            }

            // Single pane:
            else if (_twoPaneView.Mode == NavigationView.TwoPaneViewMode.SinglePane)
            {
                ViewState = SelectedItem == null ? ListDetailsViewState.List : ListDetailsViewState.Details;
                _twoPaneView.PanePriority = SelectedItem == null ? NavigationView.TwoPaneViewPriority.Pane1 : NavigationView.TwoPaneViewPriority.Pane2;
            }

            // Dual pane:
            else
            {
                ViewState = ListDetailsViewState.Both;
            }

            if (previousState != ViewState)
            {
                ViewStateChanged?.Invoke(this, ViewState);
                SetBackButtonVisibility(previousState);
            }
        }
 /// <summary>
 /// Sets focus to the relevant control based on the viewState.
 /// </summary>
 /// <param name="viewState">the view state</param>
 private void SetFocus(ListDetailsViewState viewState)
 {
     if (viewState != ListDetailsViewState.Details)
     {
         FocusItemList();
     }
     else
     {
         FocusFirstFocusableElementInDetails();
     }
 }
 /// <summary>
 /// Sets whether the selected item should change when focused with the keyboard based on the view state
 /// </summary>
 /// <param name="viewState">the view state</param>
 private void SetListSelectionWithKeyboardFocusOnVisualStateChanged(ListDetailsViewState viewState)
 {
     if (viewState == ListDetailsViewState.Both)
     {
         SetListSelectionWithKeyboardFocus(true);
     }
     else
     {
         SetListSelectionWithKeyboardFocus(false);
     }
 }
        public async Task LoadDataAsync(ListDetailsViewState viewState)
        {
            SampleItems.Clear();

            var data = await SampleDataService.GetListDetailDataAsync();

            foreach (var item in data)
            {
                SampleItems.Add(item);
            }

            if (viewState == ListDetailsViewState.Both)
            {
                Selected = SampleItems.First();
            }
        }