Через кнопки пытаюсь взаимодействовать со списком, добавлять/удалять элементы, изменять размер строк(ячеек) через Slider. Но всё это не отображается, проверил через дебаггер, свойства изменяются(в списке больше/меньше объектов), но визуально всё остается по прежнему.
Как обновить отображение измененного источника и изменение размера ячеек?
public class RootPage : ContentPage
{
ListView listView;
public RootPage ()
{
listView = new ListView() { HorizontalOptions = LayoutOptions.StartAndExpand };
listView.ItemTemplate = new DataTemplate(typeof(MyCustomCell));
listView.ItemsSource = new CustomText[] { new CustomText("asd", "bsd"), new CustomText("abra", "kadabra") };
listView.HasUnevenRows = true;
var slider = new Slider() {
VerticalOptions = LayoutOptions.EndAndExpand,
Maximum = 300,
Minimum = 100
};
slider.ValueChanged += Slider_ValueChanged;
Content = new StackLayout {
Spacing = 20,
Children = {
listView,
slider
}
};
}
private void Slider_ValueChanged(object sender, ValueChangedEventArgs e)
{
listView.RowHeight = (int)e.NewValue;
}
}
public class CustomText
{
public string T1 { get; set; }
public string T2 { get; set; }
public CustomText(string t1, string t2)
{
T1 = t1;
T2 = t2;
}
}
public class MyCustomCell : ViewCell
{
public MyCustomCell()
{
var label1 = new Label();
var label2 = new Label();
label1.SetBinding(Label.TextProperty, new Binding("T1"));
label2.SetBinding(Label.TextProperty, new Binding("T2"));
var horizontalLayout = new StackLayout()
{
BackgroundColor = Color.Olive,
Children = {
label1,
label2
}
};
View = horizontalLayout;
}
}