
Первый экран со всеми примечаниями.

После того, как я удалил первую заметку!< /p>
Недавно я начал программировать с помощью .NET MAUI. Элементы корректно удаляются из списка C#. Однако после удаления оставшиеся элементы отображаются лишь частично. Это означает, что только, например. отображается четвертый элемент. Для других элементов отображается только пустая полоса.
Мой код на данный момент:
XAML:
Код: Выделить всё
Код: Выделить всё
public partial class MainPage : ContentPage
{
private ObservableCollection notes = new ObservableCollection();
public ObservableCollection Notes
{
get { return notes; }
set { notes = value; }
}
public MainPage()
{
InitializeComponent();
notes.Add(new Note(1, "My Note1", "I'm ugly"));
notes.Add(new Note(2, "My Note2", "I'm short"));
notes.Add(new Note(3, "My Note3", "I'm smart"));
notes.Add(new Note(4, "My Note4", "I'm smart"));
//notes.Add(new Note(6, "My Note6", "I'm smart"));
//notes.Add(new Note(7, "My Note7", "I'm smart"));
//notes.Add(new Note(8, "My Note8", "I'm smart"));
//notes.Add(new Note(9, "My Note9", "I'm smart"));
this.BindingContext= Notes;
listview.ItemsSource= Notes;
}
private async void CreateNote(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//CreateNote");
}
private async void Settings(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//Settings");
}
private void ToDoSolved(object sender, EventArgs e)
{
Button button= (Button) sender ;
var id = (int)button.BindingContext;
var item = Notes.SingleOrDefault(x => x.Id == id);
if (item != null)
{
Notes.Remove(item);
Console.WriteLine(id);
}
}
async void onNoteSelected(object sender, EventArgs e)
{
Button button= (Button) sender ;
var id = (int)button.BindingContext;
//await Shell.Current.GoToAsync("NotePage" + id);
}
}
Подробнее здесь: https://stackoverflow.com/questions/747 ... hem-in-net
Мобильная версия