示例#1
0
        public TableViewPage(ITableCellFactory cellFactory)
        {
            _cellFactory = cellFactory ?? throw new ArgumentNullException(nameof(cellFactory));
            _tableView   = new TableView
            {
                Margin = new Thickness(0, -6, 0, 0)
            };
            _searchBar = new SearchBar
            {
                Margin = 0
            };
            _pageManager = new BusyPageConfigurationManager <TableViewModel>(this);

            var grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });                                                                                    // Searchbar row.
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Star
            });                                                                                   // Content row.
            grid.Children.Add(_searchBar, 0, 0);
            grid.Children.Add(_tableView, 0, 1);
            grid.Children.Add(_pageManager.ActivityIndicator, 0, 1);
            _pageManager.SetBusyHost(_tableView);

            Content = grid;
        }
        private void ConnectViewModel(IBusyPageViewModel viewModel)
        {
            _currentViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
            _pageManager.ConfigurePage(_currentViewModel);

            if (Content != null)
            {
                if (Content is Layout <View> layout)
                {
                    layout.Children.Add(_pageManager.ActivityIndicator);
                }

                _pageManager.SetBusyHost(Content);
            }
        }