Caliburn.Micro icon indicating copy to clipboard operation
Caliburn.Micro copied to clipboard

[UWP]Drag GridViewItem causing action failed to fire

Open ykwdavid opened this issue 5 years ago • 2 comments

I found that dragging a GridViewItem with disabled ItemContainerTransitions in some ways may causing Action that attached to Button within GridViewItem fails to fire.

To recreate the issues, you may be required to fulfill at least one requirement: a)Drag at reduced speed. b)Stopping on top of others GridViewItem for a while. c)Stopping on top of others GridViewItem and drawing a few circles on it. d)Overlap specific XAML control form both GridViewItem to each other for a while. In the end, you should drop the GridViewItem to other positions.

Demo project: https://github.com/ykydaird13/CMActionDetachDemo Create with UWP(Windows 10 1903) and Visual Studio 2019

GridView is defined as follows:

<GridView ItemsSource="{Binding Images}" AllowDrop="True" CanReorderItems="True">
	<GridView.ItemsPanel>
		<ItemsPanelTemplate>
			<ItemsWrapGrid ItemHeight="200" ItemWidth="200" Orientation="Horizontal"/>
		</ItemsPanelTemplate>
	</GridView.ItemsPanel>
	<GridView.ItemTemplate>
		<DataTemplate>
			<Grid>
				<Image Source="{Binding Uri}"/>
				<TextBlock Text="{Binding Id,FallbackValue=99}" FontSize="36" FontFamily="Comic Sans MS" Foreground="#FFF405FF"/>
				<Button Grid.Column="1" BorderThickness="0" Opacity="1" cm:Message.Attach="Test">
					<SymbolIcon Symbol="Edit"/>
				</Button>
			</Grid>
		</DataTemplate>
	</GridView.ItemTemplate>
	<GridView.ItemContainerTransitions>
		<TransitionCollection>
		</TransitionCollection>
	</GridView.ItemContainerTransitions>
</GridView>

Images is a BindableCollection<Image>,while Image is a public class.

ykwdavid avatar Jun 02 '20 08:06 ykwdavid

I'm not sure how this is Caliburn.Micro related, given we're attaching to the button click event, if the action is firing then it seems the issue is that button click event is firing on drag.

nigel-sampson avatar Jun 04 '20 02:06 nigel-sampson

I don't know what is the source of this bug, as it doesn't return any exceptions. But I think it is somehow related. I forgot to mention that when click event attached by default way(<Button Click="Test"/> and write Test() in .xaml.cs) and ItemContainerTransitions remains disabled, this bug disappeared. So, I am "fixing" this bug by stop using CM Message.Attach.

ykwdavid avatar Jun 04 '20 08:06 ykwdavid