using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; using Avalonia.Media.Imaging; using Demo3.Models; using System.Collections.ObjectModel; using System.Linq; namespace Demo3; public partial class Catalog : Window { public Catalog() { ObservableCollection presenters; InitializeComponent(); using var context = new ParsingdbContext(); var dataSource = context.Products.Select(product => new ProductPresenter { Productarticlenumber = product.Productarticlenumber, Productname = product.Productname, Productdescription = product.Productdescription, Productcategory = product.Productcategory, Productcost = product.Productcost, Productdiscountamount = product.Productdiscountamount, Productdiscountamountmax = product.Productdiscountamountmax, Productmanufacturer = product.Productmanufacturer, Productphoto = product.Productphoto, Productquantityinstock = product.Productquantityinstock, Productstatus = product.Productstatus }); var products = new ObservableCollection(dataSource); ProductList.ItemsSource = products; } public class ProductPresenter() : Product { Bitmap? Image { get { try { return new Bitmap(Productphoto); } catch { return null; } } } } }