public async void OnXamlRendered(FrameworkElement control) { dataGrid = control.FindDescendantByName("dataGrid") as DataGrid; if (dataGrid != null) { dataGrid.ItemsSource = await viewModel.GetDataAsync(); dataGrid.Sorting += DataGrid_Sorting; dataGrid.LoadingRowGroup += DataGrid_LoadingRowGroup; var comboBoxColumn = dataGrid.Columns.FirstOrDefault(x => x.Tag.Equals("Mountain")) as DataGridComboBoxColumn; if (comboBoxColumn != null) { comboBoxColumn.ItemsSource = await viewModel.GetMountains(); } } groupButton = control.FindDescendantByName("groupButton") as AppBarButton; if (groupButton != null) { groupButton.Click += GroupButton_Click; } rankLowItem = control.FindName("rankLow") as MenuFlyoutItem; if (rankLowItem != null) { rankLowItem.Click += RankLowItem_Click; } rankHighItem = control.FindName("rankHigh") as MenuFlyoutItem; if (rankHighItem != null) { rankHighItem.Click += RankHigh_Click; } heightLowItem = control.FindName("heightLow") as MenuFlyoutItem; if (heightLowItem != null) { heightLowItem.Click += HeightLow_Click; } heightHighItem = control.FindName("heightHigh") as MenuFlyoutItem; if (heightHighItem != null) { heightHighItem.Click += HeightHigh_Click; } }
private async void OnLoaded(object sender, RoutedEventArgs e) { Loaded -= OnLoaded; DataContext = await _viewModel.GetDataAsync(); var comboBoxColumn = dataGrid.Columns.FirstOrDefault(x => x.Header.Equals("Mountain")) as DataGridComboBoxColumn; if (comboBoxColumn != null) { comboBoxColumn.ItemsSource = await _viewModel.GetMountains(); } _ = Dispatcher.BeginInvoke(() => { _stopwatch.Stop(); LoadTimeTextBlock.Text = _stopwatch.ElapsedMilliseconds + " ms"; }, DispatcherPriority.ApplicationIdle); }
public async void OnXamlRendered(FrameworkElement control) { if (dataGrid != null) { dataGrid.Sorting -= DataGrid_Sorting; dataGrid.LoadingRowGroup -= DataGrid_LoadingRowGroup; } dataGrid = control.FindDescendant("dataGrid") as DataGrid; if (dataGrid != null) { dataGrid.Sorting += DataGrid_Sorting; dataGrid.LoadingRowGroup += DataGrid_LoadingRowGroup; dataGrid.ItemsSource = await viewModel.GetDataAsync(); dataGrid.PreparingCellForEdit += DataGrid_PreparingCellForEdit; var comboBoxColumn = dataGrid.Columns.FirstOrDefault(x => x.Tag?.Equals("Mountain") == true) as DataGridComboBoxColumn; if (comboBoxColumn != null) { comboBoxColumn.ItemsSource = await viewModel.GetMountains(); } } if (groupButton != null) { groupButton.Click -= GroupButton_Click; } groupButton = control.FindDescendant("groupButton") as AppBarButton; if (groupButton != null) { groupButton.Click += GroupButton_Click; } if (rankLowItem != null) { rankLowItem.Click -= RankLowItem_Click; } rankLowItem = control.FindName("rankLow") as MenuFlyoutItem; if (rankLowItem != null) { rankLowItem.Click += RankLowItem_Click; } if (rankHighItem != null) { rankHighItem.Click -= RankHigh_Click; } rankHighItem = control.FindName("rankHigh") as MenuFlyoutItem; if (rankHighItem != null) { rankHighItem.Click += RankHigh_Click; } if (heightLowItem != null) { heightLowItem.Click -= HeightLow_Click; } heightLowItem = control.FindName("heightLow") as MenuFlyoutItem; if (heightLowItem != null) { heightLowItem.Click += HeightLow_Click; } if (heightHighItem != null) { heightHighItem.Click -= HeightHigh_Click; } heightHighItem = control.FindName("heightHigh") as MenuFlyoutItem; if (heightHighItem != null) { heightHighItem.Click += HeightHigh_Click; } var clearFilter = control.FindName("clearFilter") as MenuFlyoutItem; if (clearFilter != null) { clearFilter.Click += this.ClearFilter_Click; } }