How to hide out a StackLayout in ViewCell?

Dear friends,

I have a custom class derived from ViewCell,my code as followed:

class QilingViewCell:ViewCell
{

    public QilingViewCell()
    {
        Image image = new Image
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
        };
        image.SetBinding(Image.SourceProperty, "IconImage");

        Label titleLabel = new Label
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            FontSize = 15,
            FontAttributes = Xamarin.Forms.FontAttributes.Bold,
            TextColor = Color.White
        };
        titleLabel.SetBinding(Label.TextProperty, "Title");

        Label descLabel = new Label
        {
            HorizontalOptions = LayoutOptions.Start,
            FontSize = 12,
            TextColor = Color.White
        };
        descLabel.SetBinding(Label.TextProperty, "Description");

        QilingCheckBox chk = new QilingCheckBox
        {
            HorizontalOptions = LayoutOptions.End,
            VerticalOptions = LayoutOptions.Center,
            IsVisible = true,
            Checked = false

        };

        chk.SetBinding(QilingCheckBox.CheckedProperty, "IsSelected");


        StackLayout viewLayoutImage = new StackLayout()
        {
            HorizontalOptions = LayoutOptions.Start,
            Orientation = StackOrientation.Vertical,
            Padding = 3,
            Children = { image }
        };

        StackLayout viewLayoutItem = new StackLayout()
        {
            HorizontalOptions = LayoutOptions.StartAndExpand,
            Orientation = StackOrientation.Vertical,
            Padding = 15,
            Children = { titleLabel, descLabel }
        };

        StackLayout checkLayoutItem = new StackLayout()
        {
            HorizontalOptions = LayoutOptions.End,
            Orientation = StackOrientation.Vertical,
            Padding = 15,
            Children = { chk }
        };


        StackLayout viewLayout = new StackLayout()
        {
            HorizontalOptions = LayoutOptions.StartAndExpand,
            Orientation = StackOrientation.Horizontal,
            BackgroundColor = Color.Black,
            Children = { viewLayoutImage, viewLayoutItem, checkLayoutItem }
        };

        View = viewLayout;
    }
}

My question is HOW TO HIDE OUT THE "checkLayoutItem" StackLayout ?It seems that StackLayout.IsVisible does not work!

Any help will be appreciated!

Jerry

Answers

  • JerryLiangJerryLiang USMember

    I have success it:

    Add a binding :

    chk.SetBinding(QilingCheckBox.IsVisisbleProperty, "IsVisible");

    then update ListView.ItemSource:

                foreach (QilingListItem cur in lv.ItemsSource)
                {                   
                    cur.IsVisible = true;
                }
    

    That's ALL!

Sign In or Register to comment.