Dynamic binding a different item in item template?

unknown123unknown123 Member ✭✭✭

In a list view item template binding a different items dynamically but it binded only the first items.

Tagged:

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Please show your code.
    How did you make this binding dynamically? What requirement do you expect to archive?

  • unknown123unknown123 Member ✭✭✭

    I made this by grouping the list view but in the item template i want to show different items like (Slidder,checkbox,radio button).

  • LandLuLandLu Member, Xamarin Team Xamurai

    @Chikku22 Without your code or sample, we can't find out what parts caused the issue.

  • unknown123unknown123 Member ✭✭✭
    <ListView  RowHeight="35" IsGroupingEnabled="True" >
                    <ListView.GroupHeaderTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <StackLayout >
                                      <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" Margin="20,0,20,0">
                                        <Label Text="{Binding Heading}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
                                        <Image Source="{Binding Image}" HorizontalOptions="End"/>
                                    </StackLayout>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.GroupHeaderTemplate>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <StackLayout Orientation="Vertical" >                                                           
                                    <StackLayout Orientation="Horizontal">
                                        <Label Text="{Binding Items}" VerticalOptions="Center" HorizontalOptions="Start"/>
                                        <Image Source="{Binding Option}" HorizontalOptions="EndAndExpand" WidthRequest="24"/>
                                    </StackLayout>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
    

    Here Is my xaml list view

    And i want to bind the stepper in the 1st item of the itemtemplate

  • LandLuLandLu Member, Xamarin Team Xamurai

    I'm really confused about what you expected to achieve.
    Do you mean you want some of the controls in the ViewCell to be hidden or visible depending on the conditions?
    If so, you could create some bool properties in your items source model:

    bool isStepperVisible;
    public bool IsStepperVisible
    {
        set
        {
            isStepperVisible = value;
            onPropertyChanged();
        }
        get
        {
            return isStepperVisible;
        }
    }
    

    Then bind it in the XAML:

    <ViewCell>
        <StackLayout Orientation="Vertical" >
            <StackLayout Orientation="Horizontal">
                <Label Text="{Binding Items}" VerticalOptions="Center" HorizontalOptions="Start"/>
                <Image Source="{Binding Option}" HorizontalOptions="EndAndExpand" WidthRequest="24"/>
                <Stepper IsVisible="{Binding IsStepperVisible}"/>
            </StackLayout>
        </StackLayout>
    </ViewCell>
    

    Moreover do not forget to enable the HasUnevenRows of list view.

    If this is not what you want. Please specify your requirement.

  • unknown123unknown123 Member ✭✭✭
    edited March 14

    '

  • LandLuLandLu Member, Xamarin Team Xamurai

    I really can't understand what you want to implement.
    Try to post:

    • What did you expect to achieve with some screenshots
    • What have you done with your sample and screenshots
    • What's your requirement
  • unknown123unknown123 Member ✭✭✭

    I would like to bind the slider and some items dynamically to itemtemplate

    but im not able to bind the slider like this???

  • unknown123unknown123 Member ✭✭✭

    Except slider remaining items are binded but in the slider region i will get an empty space

Sign In or Register to comment.