Open alex3696 opened 2 months ago
It looks like TouchBehavior doesn’t work anywhere in the templates because https://github.com/CommunityToolkit/Maui/pull/1673#issuecomment-1969513311 After changing (delete, add) the collection (ItemsSource="{Binding Items}") ItemTemplate in CollectionView in LongPress the element is selected incorrectly, while in GestureRecognizers everything is correct.
<CollectionView
ItemsLayout="VerticalList"
ItemsSource="{Binding Items}"
SelectedItems="{Binding SelectedItems}"
SelectionMode="{Binding SelectionMode}" >
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="vm:ItemVM">
<StackLayout>
<Border HeightRequest="50">
<Border.Behaviors>
<mct:TouchBehavior
LongPressCommand="{Binding Path=BindingContext.CmdLongPress, Source={x:Reference ThisPage}}"
LongPressCommandParameter="{Binding .}" />
</Border.Behaviors>
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.CmdEdit, Source={x:Reference ThisPage}}"
CommandParameter="{Binding .}"/>
</Border.GestureRecognizers>
<Grid ColumnDefinitions="60,30*">
<Label
Grid.Column="0"
Style="{StaticResource TitleLabel}"
Text="{Binding Key}" />
<Label
Grid.Column="1"
Style="{StaticResource TitleLabel}"
Text="{Binding Value}" />
</Grid>
</Border>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
may be it same https://devblogs.microsoft.com/dotnet/dotnet-8-performance-improvements-in-dotnet-maui/#patterns-that-cause-leaks:-c#-events
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
When you use TouchBehavior in styles, an animation occurs when you click and hover over another element. 1) In picture No. 2 there are 5 elements in the CollectionView, when you hover and click on element 2, the animation is triggered on element 4 2) In picture No. 3 there are 4 elements in the VertiCalStackLayout, when you hover and click on element 1, the animation is triggered on element 4 in the CollectionView
Expected Behavior
When you use TouchBehavior in styles, the animation should occur when you click and hover on the same element where the cursor or click is located, like the element in picture #1.
Steps To Reproduce
1)open and run solution in repository 2)try hover on elements in colums 2 and 3 in and press 3)animation will occur on the wrong elements
Link to public reproduction project repository
https://github.com/alex3696/BugMauiTkBehavior.git
Environment
workaround
use TouchBehavior directly
instead