I’m developing an app to handle an inventory for Android, when it run on the device itselft crash (i’m ussing a Samsung S 20+ and A 21S, but if it is connected to the visual studio on debug mode it works fine, the form it is a collectionview tie to an observable collection, the view model has 2 set of viariables on which conteing all records and the other handle the filters, on the initial both has the same sub set of data (No filter apply), but when i set the value of the second (which is the one used on the CollectionView) the app crash.
Ussing Net Maui 8.0.60 and the target it is 14v min Version 10
public InventoryViewModel()
{
if (string.IsNullOrEmpty(Title))
Title = "Inventario";
SelectionMode = SelectionMode.Multiple;
LoadInventory();
}
public void LoadInventory()
{
try
{
Inventory = new ObservableCollection<ProductsModel>();
Inventory.Add(new ProductsModel { ProductId = 1, ProductName = "Perfume 1", ProductCategory = "P", Quantity = 1, UnitPrice = 3.53M, BarCode = "1234", IsImageOnServer = false });
Inventory.Add(new ProductsModel { ProductId = 2, ProductName = "Perfume 2", ProductCategory = "P", Quantity = 2, UnitPrice = 4.63M, BarCode = "5697", IsImageOnServer = false });
Inventory.Add(new ProductsModel { ProductId = 3, ProductName = "Perfume 3", ProductCategory = "P", Quantity = 3, UnitPrice = 5.73M, BarCode = "8741", IsImageOnServer = false });
Inventory.Add(new ProductsModel { ProductId = 4, ProductName = "Perfume 4", ProductCategory = "P", Quantity = 2, UnitPrice = 6.83M, BarCode = "9965", IsImageOnServer = false });
**SearchResults = Inventory;** //Here is where the app crash.
}
catch (Exception)
{
throw;
}
}
I been trying:
- Define the observable colletion and then add records to it
- Assing directly to the observable collection the values intead of the first then the secondone.
- Create a list then convert to observable.
Adding some delay when declare and then add the data, thinking it was a time issue, but not luck.