Stacklayout visibility not working inside listview

AshokAshok USMember ✭✭✭
edited October 2018 in Xamarin.Forms

Hi,I am using stacklayout inside listview like

<ListView ItemsSource="{Binding Items}" x:Name="listView" SeparatorVisibility="None" HasUnevenRows="True" SelectedItem="{Binding SelectedItem}">
                    <ListView.Header>
-------
-------
</ListView.Header>
       <ListView.ItemTemplate>
              <DataTemplate>
                   <ViewCell>
                       <Grid>
                 ------- Column1
                 -------Column2
                 -------Column3
<StackLayout x:Name="completeService"  Padding="0" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" Spacing="0" Grid.Column="4" IsVisible="{Binding CompleteServiceVisiblity}">
                                        <!--Converter={StaticResource boolConvert}-->
                                        <Label  Text="{Binding CompleteServiceText}">
                                            <Label.GestureRecognizers>
                                                <TapGestureRecognizer NumberOfTapsRequired="1" Tapped="CompleteService_Tapped"/>
                                            </Label.GestureRecognizers>
                                        </Label>
                                        <BoxView x:Name="customBox" BackgroundColor="#658fb2" HeightRequest="1"/>
                                    </StackLayout>
                                </Grid>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>

I set my stacklayout visibility false in my ViewModel like

 public class MyViewModel : INotifyPropertyChanged
    {
      private bool _completeServiceVisiblity;
        public bool CompleteServiceVisiblity
        {
            get { return _completeServiceVisiblity; }
            set
            {
                _completeServiceVisiblity = value;
                OnPropertyChanged(nameof(CompleteServiceVisiblity));
            }
        }

    private string _completeServiceText { get; set; }
    public string CompleteServiceText
    {
        get { return _completeServiceText; }
        set
        {
            _completeServiceText = value;
            OnPropertyChanged("CompleteServiceText");
        }
    }

       public MyViewModel ()
        {
            CompleteServiceVisiblity = false;
            CompleteServiceText = "Complete Service";
        }
       public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string property)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(property));
        }
    }

but my stacklayout is still showing!! and if I set Visibility true CompleteServiceText is not showing. Can anybody please help me what I am doing worng.

Answers

Sign In or Register to comment.