bind image with MVVM not working.

i'm working on the FormWizard,
i'm using MVVM for showing image of active tab of form,

this is my model which i'm using,

public class WizardViewModel : INotifyPropertyChanged
    {
        public string SectionTitle { get; set; }

        public string SectionId { get; set; }

        public bool iscurrenttab { get; set; }

        public bool IsEnabled { get; set; }

        public string selctedimagename { get; set; } = CustomImages.DeactiveWizardImageSource;

        public String SelectedImageName { 
            get {
                return selctedimagename;
            } 
            set {
                selctedimagename = value;
                PropertyChanged(this, new PropertyChangedEventArgs("SelectedImageName"));
            }
        } 

        public bool IsCurrentTab
        {
            get
            {
                return iscurrenttab;
            }
            set
            {
                iscurrenttab = value;
                IsEnabled = true;
                if (value)
                {
                    SelectedImageName = CustomImages.ActiveWizardImageSource;

                }
                else
                {
                    SelectedImageName = CustomImages.InactiveWizardImageSource;
                    //PropertyChanged(this, new PropertyChangedEventArgs("SelectedImageName"));
                }
                //PropertyChanged(this, new PropertyChangedEventArgs("IsCurrentTab"));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged = delegate { };
    }

i had ObservableCollection which is collection of my view model like this,

public ObservableCollection<WizardViewModel> Bindings { get; set; }

also i'mcreating tabs of wizard with this collection, and binding imagelike this:

for (int i = 0; i < Bindings.Count; i++)
                    {
                        var Dataobj = Bindings[i];

                        MyLabel lblTabName = new MyLabel
                        {
                            Style = CustomStyles.MyLabelStyle,
                            Text = Dataobj.SectionTitle,
                            ClassId = "lbl" + i.ToString(),
                        };

                        Image StepIcon = new Image
                        {
                            ClassId = "Img_" + Bindings[i].SectionId,
                            HorizontalOptions = LayoutOptions.Start,
                            VerticalOptions = LayoutOptions.CenterAndExpand,
                            //Source = Dataobj.SelectedImageName
                        };
                        StepIcon.SetBinding(Image.SourceProperty, "Source", BindingMode.Default);
                        StepIcon.BindingContext = new { Source = Bindings[i].SelectedImageName};


                        BoxView Tabline = new BoxView
                        {
                            ClassId = "TB" + i.ToString(),
                            Style = CustomStyles.TablineStyle,
                            IsVisible = false
                        };

                        StackLayout StepLayout = new StackLayout
                        {
                            ClassId = "Step_" + Bindings[i].SectionId,
                            Orientation = StackOrientation.Horizontal,
                            Padding = 0,
                            Spacing = 0,
                            Children = {
                                StepIcon
                            },
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions = LayoutOptions.CenterAndExpand,
                        };

                        StackLayout MainStepLayout = new StackLayout
                        {
                            ClassId = Bindings[i].SectionId.ToString(),
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions = LayoutOptions.Start,
                            BackgroundColor = Color.Transparent,
                            Orientation = StackOrientation.Vertical,
                            Spacing = 5,
                            Children = {
                                StepLayout,
                                lblTabName
                            }
                        };
                        //lblTabName.GestureRecognizers.Add(TabPaneTGR);
                        MainStepLayout.GestureRecognizers.Add(TabPaneTGR);

                        if (i + 1 < Bindings.Count)
                        {
                            Tabline.IsVisible = true;
                            StepLayout.Children.Add(Tabline);
                            MainContentGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                        }
                        else
                        {
                            MainContentGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
                            lblTabName.WidthRequest = 70;
                        }

                        MainContentGrid.Children.Add(MainStepLayout, i, 0);
                    }

but my image controlwhichis in loop not binding when ichange the value ofproperty IsCurrentTab plz help,

Sign In or Register to comment.