Esempio n. 1
0
        public ProductItem(Product product)
        {
            Label = string.Format(" {0} | {1} | {2:C} ", product.ToString(), product.Category.ToString(), product.Cost.ToString());
#if WINDOWS_UWP || WPF
            ImageSource = new Image();
#endif

#if WINDOWS_UWP
            LoadImageAsync(product);
#elif XF
            ImageSource = ImageSource.FromStream(() => new MemoryStream(product.Image));
#else
            using (var stream = new MemoryStream(product.Image))
            {
#if WPF
                ImageSource.BeginInit();
                ImageSource.CacheOption  = BitmapCacheOption.OnLoad;
                ImageSource.StreamSource = stream;
                ImageSource.EndInit();
#else
                ImageSource = Image.FromStream(stream);
#endif
            }
#endif
        }