Reputation: 33
One of my maui android project I have a collection view in a page.
I set the properties of the colection view like this:
<CollectionView x:Name="ModelList"
SelectionMode="None"
IsGrouped="False"
ItemSizingStrategy="MeasureAllItems"
ItemsSource="{Binding Models}"
VerticalOptions="FillAndExpand">
<CollectionView.ItemsLayout>
<GridItemsLayout Span="2" Orientation="Vertical"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="models:Model">
<VerticalStackLayout Spacing="3" HorizontalOptions="Center" Margin="0,0,0,10">
<views:CustomView
x:Name="Cstm"
IsBusy="{Binding IsBusy, Source={RelativeSource AncestorType={x:Type viewmodel:ViewModel}}}" <-- IsBusy property is bindable Property.-->
ControlTemplate="{StaticResource TappedView}">
<views:CustomView.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ModelDetailsPageCommand, Source={RelativeSource AncestorType={x:Type viewmodel:ProjectPageViewModel}}}" CommandParameter="{Binding Id}"/>
</views:CustomView.GestureRecognizers>
</views:CustomView>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Collection view's item template populates with custom view and that custom view's control template is a custom control. And its layout like this:
<ControlTemplate x:Key="CustomControl">
<Border x:Name="CustomLayout">
<Grid>
<Border attached:ControlTappedAttachedProperty.Value="{TemplateBinding IsBusy}"> <--AttachedProperty-->
<Image HeightRequest="60">
<Image.Source>
<FontImageSource FontFamily="Font" Glyph="{x:Static Font.ThereIsAProblem}" Color="{StaticResource YsSomeColor}" />
</Image.Source>
</Image>
</Border>
</Grid>
</Border>
</ControlTemplate>
This controls attached property's value's binding the bindable property of the custom control.
Attached property simply animates the visual element attached to.
Here is the problem. When tapped the item in collection view all the items animates. Not just the one that was tapped.
Tried:
<views:CustomView/>
) instead of the custom control not effective. Same problem.So... I am so confused. Any help any ideas would be very much preciated. Thanks in advance.
Upvotes: 0
Views: 71