public void AdaptLayoytToScreenWidth(bool narrow) { if (narrow && (!testResultsNarrow.HasValue || !testResultsNarrow.Value)) { ClearBindings(); testResultsNarrow = true; var tr = new TestResultsNarrow() { BindingContext = ViewModelContainer.DriveTestViewModel, IsFooterVisible = true, ShowFooterIfEmptyItems = true }; tr.SetBinding(GridRepeater.ItemsSourceProperty, nameof(ViewModelContainer.DriveTestViewModel.TestResults)); testResultsPlaceholder.Children.Clear(); testResultsPlaceholder.Children.Add(tr); } else if (!narrow && (!testResultsNarrow.HasValue || testResultsNarrow.Value)) { ClearBindings(); testResultsNarrow = false; var tr = new TestResults() { BindingContext = ViewModelContainer.DriveTestViewModel, IsFooterVisible = true, ShowFooterIfEmptyItems = true }; tr.SetBinding(GridRepeater.ItemsSourceProperty, nameof(ViewModelContainer.DriveTestViewModel.TestResults)); testResultsPlaceholder.Children.Clear(); testResultsPlaceholder.Children.Add(tr); } }
private void AdaptLayoytToScreenWidth() { var testResultsNarrow = false; var testSessionsNarrow = false; var narrowWidth = 640; SizeChanged += (s, e) => { buttons.AdaptLayoytToScreenWidth(Width < narrowWidth); if (Width < narrowWidth) { if (!testResultsNarrow) { testResultsNarrow = true; var tr = new TestResultsNarrow() { BindingContext = ViewModelContainer.DriveTestViewModel, IsFooterVisible = true, ShowFooterIfEmptyItems = true }; tr.SetBinding(GridRepeater.ItemsSourceProperty, nameof(ViewModelContainer.DriveTestViewModel.TestResults)); testResultsPlaceholder.Children.Clear(); testResultsPlaceholder.Children.Add(tr); } if (!testSessionsNarrow) { testSessionsNarrow = true; var ts = new TestSessionsNarrow(); testSessionsPlaceholder.Children.Clear(); testSessionsPlaceholder.Children.Add(ts); } } else if (Width >= narrowWidth) { if (testResultsNarrow) { testResultsNarrow = false; var tr = new TestResults() { BindingContext = ViewModelContainer.DriveTestViewModel, IsFooterVisible = true, ShowFooterIfEmptyItems = true }; tr.SetBinding(GridRepeater.ItemsSourceProperty, nameof(ViewModelContainer.DriveTestViewModel.TestResults)); testResultsPlaceholder.Children.Clear(); testResultsPlaceholder.Children.Add(tr); } if (testSessionsNarrow) { testSessionsNarrow = false; var ts = new TestSessions(); testSessionsPlaceholder.Children.Clear(); testSessionsPlaceholder.Children.Add(ts); } } }; }