Cardview: Cannot set initial position via SelectedItem binding

Created on 9 Oct 2019  路  25Comments  路  Source: AndreiMisiukevich/CardView

Hi Andrei,

I am using the 'CoverFlowView' and when i bind the ItemSource and set the SelectedItem to the last item in the list, it keeps resetting the SelectedItem to the first item in the list.

Any tips?

Regards,

Jorg

bug resolved

All 25 comments

Hi @jorgvanriet could you please share your xaml?

<panCardView:CoverFlowView 
x:Name="CoverFlowView1" 
ItemsSource="{Binding Path=BindingContext.ProgressList, Source={x:Reference Name=DevelopmentViewName}}" 
VerticalOptions="FillAndExpand" 
IsCyclical="False" 
SelectedItem="{Binding Path=BindingContext.SelectedItem, Source={x:Reference Name=DevelopmentViewName}, Mode=OneWay}">

        <panCardView:CoverFlowView.ItemTemplate>
            <DataTemplate>
                <StackLayout VerticalOptions="FillAndExpand" Padding="20">
                    <Label Text="{Binding Title}" Style="{StaticResource LabelPinkLarge}" />
                    <Label Text="{Binding Week, StringFormat='Week {0}'}" Style="{StaticResource LabelPink}" />
                    <Label Text="{Binding Message}" Style="{StaticResource LabelBlack}" />
                </StackLayout>

            </DataTemplate>
        </panCardView:CoverFlowView.ItemTemplate>

    </panCardView:CoverFlowView>

Sorry quotes are messing it up

Mode=OneWay

I presume should be a default (two-way, cuz you want to keep it updated in case of any swipes)

SelectedItem="{Binding Path=BindingContext.SelectedItem, Source={x:Reference Name=DevelopmentViewName}}"

It's not the OneWay that was just something i tried sorry

@jorgvanriet so, what is the issue?
You cannot select initial item with SelectedItem property, right? But then it works, yep?

Yes, unable to set the initial item.

@jorgvanriet thx, I'll take a look on my sample )

    <cards:CarouselView 
        ItemsSource="{Binding Items}"
        SelectedItem="{Binding CurrentItem}">

        <cards:CarouselView.ItemTemplate>
            <DataTemplate>
                <ContentView>
                </ContentView>
            </DataTemplate>
        </cards:CarouselView.ItemTemplate>
    </cards:CarouselView>

Works fine for me

image

try to build a small sample

btw there is SelectedIndex property if you want to use index instead of an item

Andrei,

I am using the CoverFlowView and your example is the CarouselView.
When i use the SelectedIndex instead of the SelectedItem it works fine.

When i use the SelectedItem is does not work.

@jorgvanriet can I reproduce this issue on my CoverFlowView sample?

You mean you can reproduce or you cannot?

@jorgvanriet sorry. It was a question :) Is it possible to reproduce this issue on my sample? Are you able to do it?

As a work around i am now binding to the SelectedIndex where i am setting the SelectedItem (i need it for the information it holds)

I will try to reproduce it.

It works with the simple version
I have no idea what the difference is between SelectedIndex and SelectedItem
And no clue why 'SelectedIndex' works and 'SelectedItem' doesn't

Tnx for the help

@jorgvanriet can you build a sample that represents this issue?

Seems I've fixed it

@jorgvanriet I will create a release on this/next week :) if it's not super urgent for you

Tnx alot Andrei !
I will be looking forward to the update :)

Just to let you know it works like a charm!
Tnx for the quick response!

@jorgvanriet thanks for the feedback :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IgorPopov56 picture IgorPopov56  路  4Comments

stealthcold picture stealthcold  路  6Comments

shoeIT picture shoeIT  路  6Comments

InquisitorJax picture InquisitorJax  路  6Comments

jungjanos picture jungjanos  路  8Comments