コード例 #1
0
        public CarView()
        {
            InitializeComponent();
            CarBrand.SetBinding(Image.SourceProperty, new Binding("Car.Brand", source: this));
            //if(Car.CarImage_1 != null || Car.CarImage_1.Any())
            //{
            //    var stream1 = new MemoryStream(Car.CarImage_1 ?? new byte[] { });
            //    CarImage.Source = ImageSource.FromStream(() => stream1);
            //}
            CarImage.SetBinding(CachedImage.SourceProperty, new Binding("Car.CarImageSource", source: this));
            CarName.SetBinding(Label.TextProperty, new Binding("Car.Name", source: this));
            //carouselForCarImages.SetBinding(CarouselViewControl.ItemsSourceProperty, new Binding("Car.Images", source: this));
            Available.SetBinding(Button.TextProperty, new Binding("Car.Available", BindingMode.Default, new FromBoolToAvailableText(), source: this));
            Available.SetBinding(Button.OpacityProperty, new Binding("Car.Available", BindingMode.Default, new FromBoolToAvailableOpacity(), source: this));
            Available.SetBinding(Button.BackgroundColorProperty, new Binding("Car.Available", BindingMode.Default, new FromBoolToAvailableBackgroundColor(), source: this));
            this.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => {
                    this.Clicked?.Invoke(this, EventArgs.Empty);

                    if (Command != null)
                    {
                        if (Command.CanExecute(CommandParameter))
                        {
                            Command.Execute(CommandParameter);
                        }
                    }
                })
            });
        }