private async Task Init() { _viewModel = new CountyStandingsViewModel(); BindingContext = _viewModel; _viewModel.GetChapters(); _viewModel.GetYears(); _viewModel.GetYearFractions(); var lblChapter = new Label { VerticalOptions = LayoutOptions.Center, Text = "Indicator:" }; _pickerChapters = new PickerWithNoSpellCheck() { HorizontalOptions = LayoutOptions.FillAndExpand }; foreach (var chapter in _viewModel.ChapterList) { _pickerChapters.Items.Add(chapter.Key); } var lblYear = new Label { VerticalOptions = LayoutOptions.Center, Text = "An:" }; _pickerYears = new PickerWithNoSpellCheck() { HorizontalOptions = LayoutOptions.FillAndExpand }; foreach (var year in _viewModel.YearList) { _pickerYears.Items.Add(year); } var lblYearFraction = new Label { VerticalOptions = LayoutOptions.Center, Text = "Luna:" }; _pickerYearFractions = new PickerWithNoSpellCheck() { HorizontalOptions = LayoutOptions.FillAndExpand }; foreach (var yearFraction in _viewModel.YearFractionList) { _pickerYearFractions.Items.Add(yearFraction); } var degStandings = new GridControl(); degStandings.IsReadOnly = true; degStandings.HorizontalOptions = LayoutOptions.FillAndExpand; degStandings.Columns.Add(new TextColumn() { Caption = "Pozitie", FieldName = "Position", IsReadOnly = true, AllowSort = DefaultBoolean.False }); degStandings.Columns.Add(new TextColumn() { Caption = "Judet", FieldName = "County", IsReadOnly = true, AllowSort = DefaultBoolean.False }); var valueColumn = new TextColumn() { FieldName = "Value", IsReadOnly = true, AllowSort = DefaultBoolean.False }; valueColumn.SetBinding(TextColumn.CaptionProperty, new Binding("ValueColumnCaption", source: _viewModel)); degStandings.Columns.Add(valueColumn); degStandings.ItemsSource = _viewModel.Standings; degStandings.RowTap += degAverageGrosSalary_RowTap; degStandings.SetBinding(GridControl.IsVisibleProperty, "HasData"); var lblNoData = new Label() { HorizontalOptions = LayoutOptions.FillAndExpand, Text = "Nu exista date disponibile pentru intervalul selectat", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, FontSize = 27, }; var btnForceDataLoading = new Button() { Text = "Forteaza incarcarea datelor", }; btnForceDataLoading.Clicked += btnForceDataLoading_Clicked; var stackNoData = new StackLayout() { VerticalOptions = LayoutOptions.FillAndExpand, Spacing = 20, Padding = new Thickness(0), Children = { lblNoData, btnForceDataLoading } }; stackNoData.SetBinding(Label.IsVisibleProperty, "DoesNotHaveData"); this.Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness( left: 0, right: 0, bottom: 0, top: Device.OnPlatform(iOS: 20, Android: 5, WinPhone: 0)), Children = { new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 2), Children = { lblChapter, _pickerChapters } }, new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Children = { lblYear, _pickerYears, lblYearFraction, _pickerYearFractions } }, degStandings, stackNoData } }; _pickerChapters.SelectedIndex = Settings.StandingsChapter; _pickerYears.SelectedIndex = _pickerYears.Items.IndexOf(App.LastYearAvailableData.ToString()); _pickerYearFractions.SelectedIndex = _pickerYearFractions.Items.IndexOf(App.LastMonthAvailableData.ToString()); _pickerChapters.SelectedIndexChanged += pickerChapters_SelectedIndexChanged; _pickerYears.SelectedIndexChanged += _pickerYears_SelectedIndexChanged; _pickerYearFractions.SelectedIndexChanged += _pickerYearFractions_SelectedIndexChanged; await LoadData(); }
private async Task Init() { _viewModel = new CountyStandingsViewModel(); _viewModel.GetChapters(); _viewModel.GetYears(); _viewModel.GetYearFractions(); var lblChapter = new Label { VerticalOptions = LayoutOptions.Center, Text = "Indicator:" }; _pickerChapters = new Picker() { HorizontalOptions = LayoutOptions.FillAndExpand }; foreach (var chapter in _viewModel.ChapterList) { _pickerChapters.Items.Add(chapter.Key); } _pickerChapters.SelectedIndexChanged += pickerChapters_SelectedIndexChanged; var lblYear = new Label { VerticalOptions = LayoutOptions.Center, Text = "An:" }; _pickerYears = new Picker() { HorizontalOptions = LayoutOptions.FillAndExpand }; foreach (var year in _viewModel.YearList) { _pickerYears.Items.Add(year); } _pickerYears.SelectedIndexChanged += _pickerYears_SelectedIndexChanged; var lblYearFraction = new Label { VerticalOptions = LayoutOptions.Center, Text = "Luna / semestru / trimestru:" }; _pickerYearFractions = new Picker() { HorizontalOptions = LayoutOptions.FillAndExpand }; foreach (var yearFraction in _viewModel.YearFractionList) { _pickerYearFractions.Items.Add(yearFraction); } _pickerYearFractions.SelectedIndexChanged += _pickerYearFractions_SelectedIndexChanged; await LoadData(); var degAverageGrosSalary = new GridControl(); degAverageGrosSalary.IsReadOnly = true; degAverageGrosSalary.HorizontalOptions = LayoutOptions.FillAndExpand; degAverageGrosSalary.Columns.Add(new TextColumn() { Caption = "Pozitie", FieldName = "Position", IsReadOnly = true, AllowSort = DefaultBoolean.False }); degAverageGrosSalary.Columns.Add(new TextColumn() { Caption = "Judet", FieldName = "County", IsReadOnly = true, AllowSort = DefaultBoolean.False }); var valueColumn = new TextColumn() { FieldName = "Value", IsReadOnly = true, AllowSort = DefaultBoolean.False }; valueColumn.SetBinding(TextColumn.CaptionProperty, new Binding("ValueColumnCaption", source: _viewModel)); degAverageGrosSalary.Columns.Add(valueColumn); degAverageGrosSalary.ItemsSource = _viewModel.Standings; this.Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness( left: 0, right: 0, bottom: 0, top: Device.OnPlatform(iOS: 20, Android: 0, WinPhone: 0)), Children = { new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Children = { lblChapter, _pickerChapters } }, new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Children = { lblYear, _pickerYears, lblYearFraction, _pickerYearFractions } }, degAverageGrosSalary, } }; _pickerChapters.SelectedIndex = 0; }