Код: Выделить всё
// LandingViewModel.cs
using PropertyApp.Model;
using PropertyApp.View;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace PropertyApp.ViewModel
{
public class LandingViewModel : BaseViewModel
{
public List Sections = new List { "Trending", "Popular", "Buy", "Rent" };
public List
Properties => PropertyRepo.AllProperties;
public Property SelectedProperty { get; set; }
public ICommand PropertySelected => new Command(obj =>
{
if (SelectedProperty != null)
Application.Current.MainPage.Navigation.PushAsync(new DetailsPage(SelectedProperty));
SelectedProperty = null;
});
}
}
Код: Выделить всё
// LandingPage.cs
using PropertyApp.ViewModel;
namespace PropertyApp.View
{
public partial class LandingPage : ContentPage
{
public LandingPage()
{
InitializeComponent();
this.BindingContext = new LandingViewModel();
(SectionList.Children[0] as RadioButton).IsChecked = true;
}
}
}
Код: Выделить всё
(SectionList.Children[0] as RadioButton).IsChecked = true;
System.ArgumentOutOfRangeException: «Индекс вышел за пределы допустимого диапазона. Должно быть неотрицательным и меньше размера коллекции. (Параметр «индекс»)
Может ли кто-нибудь сказать мне, где я ошибаюсь? Я хочу активировать переключатели для указанного списка разделов, но в эмуляторе Android эти кнопки не отображаются.
Подробнее здесь: https://stackoverflow.com/questions/785 ... ed-in-maui