You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed, that my app didn't worked right on iPhone.
So here is what I did to reproduce the error and make it hopefully noticeable to the Developer :-)
Starting with a new Xamarin Forms Project in Visual Studio (newest from every version)
Get the Refractored.MvvmHelpers 1.6.2 and inlcude it only in the base project.
The only File you have to create is that TestItem.cs inside the Models-Folder
You can simply copy and paste and might notice, that I have one Observable Collection bind to an CollectionView, which is working and one ObservableCollection with IGrouping bind to an CollectionView, which does trouble.
The Fun-Thing is... if you are doing a clear and a fill not in one method, it will work.
Models:
TestItem.cs --> public class TestItem
{
public string TestText { get; set; }
public string NameSort
{
get
{
if (string.IsNullOrWhiteSpace(TestText) || TestText.Length == 0)
return "?";
return TestText[0].ToString().ToUpper();
}
}
}
ViewModel
AboutViewModel.cs -->
using ErrorTesting.Models;
using MvvmHelpers;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
using Xamarin.Essentials;
using Xamarin.Forms;
namespace ErrorTesting.ViewModels
{
public class AboutViewModel : BaseViewModel
{
public ObservableCollection TestCollection { get; set; }
public ObservableRangeCollection<IGrouping<string, TestItem>> GefilterteUndGruppierteObjekte { get; set; }
public AboutViewModel()
{
TestCollection = new ObservableCollection<TestItem>();
GefilterteUndGruppierteObjekte = new ObservableRangeCollection<IGrouping<string, TestItem>>();
Title = "About";
OpenWebCommand = new Command(async () => await Browser.OpenAsync("https://aka.ms/xamarin-quickstart"));
DeleteElementCommand = new Command(LoescheDatensatz);
ClearElementCommand = new Command(ClearDatensatz);
FillElementCommand = new Command(FillDatensatz);
FehlerElementCommand = new Command(FehlerDatensatz);
DeleteTestElementCommand = new Command(LoescheTestDatensatz);
ClearTestElementCommand = new Command(ClearTestDatensatz);
FillTestElementCommand = new Command(FillTestDatensatz);
FehlerTestElementCommand = new Command(FehlerTestDatensatz);
ErzeugeTestdaten();
ErzeugeDasIGrouping();
}
public ICommand OpenWebCommand { get; }
public ICommand DeleteElementCommand { get; }
public ICommand ClearElementCommand { get; }
public ICommand FillElementCommand { get; }
public ICommand FehlerElementCommand { get; }
public ICommand DeleteTestElementCommand { get; }
public ICommand ClearTestElementCommand { get; }
public ICommand FillTestElementCommand { get; }
public ICommand FehlerTestElementCommand { get; }
private void ErzeugeTestdaten()
{
TestCollection.Add(new TestItem { TestText = "Erstes Element" });
TestCollection.Add(new TestItem { TestText = "Zweites Element" });
TestCollection.Add(new TestItem { TestText = "Drittes Element" });
TestCollection.Add(new TestItem { TestText = "Viertes Element" });
}
private void LoescheTestDatensatz()
{
if (TestCollection.Count == 0)
return;
TestCollection.RemoveAt(0);
}
private void ClearTestDatensatz()
{
TestCollection.Clear();
}
private void FillTestDatensatz()
{
ErzeugeTestdaten();
}
private void FehlerTestDatensatz()
{
TestCollection.Clear();
ErzeugeTestdaten();
}
private void LoescheDatensatz()
{
if (GefilterteUndGruppierteObjekte.Count == 0)
return;
GefilterteUndGruppierteObjekte.RemoveAt(0);
}
private void ClearDatensatz()
{
GefilterteUndGruppierteObjekte.Clear();
}
private void FillDatensatz()
{
ErzeugeDasIGrouping();
}
private void FehlerDatensatz()
{
GefilterteUndGruppierteObjekte.Clear();
ErzeugeDasIGrouping();
}
public void ErzeugeDasIGrouping()
{
var items = TestCollection.GroupBy(gefiltertesObjekt => gefiltertesObjekt.NameSort);
GefilterteUndGruppierteObjekte.AddRange(items);
}
}
I noticed, that my app didn't worked right on iPhone.
So here is what I did to reproduce the error and make it hopefully noticeable to the Developer :-)
Starting with a new Xamarin Forms Project in Visual Studio (newest from every version)
Get the Refractored.MvvmHelpers 1.6.2 and inlcude it only in the base project.
The only File you have to create is that TestItem.cs inside the Models-Folder
You can simply copy and paste and might notice, that I have one Observable Collection bind to an CollectionView, which is working and one ObservableCollection with IGrouping bind to an CollectionView, which does trouble.
The Fun-Thing is... if you are doing a clear and a fill not in one method, it will work.
Models:
TestItem.cs --> public class TestItem
{
public string TestText { get; set; }
ViewModel
AboutViewModel.cs -->
using ErrorTesting.Models;
using MvvmHelpers;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
using Xamarin.Essentials;
using Xamarin.Forms;
namespace ErrorTesting.ViewModels
{
public class AboutViewModel : BaseViewModel
{
public ObservableCollection TestCollection { get; set; }
public ObservableRangeCollection<IGrouping<string, TestItem>> GefilterteUndGruppierteObjekte { get; set; }
}
And Last the View
AboutPage.xml -->
The text was updated successfully, but these errors were encountered: