ratishphilip / CompositionProToolkit

Collection of Helper classes and controls (using Win2d) for Windows.UI.Composition
MIT License
235 stars 29 forks source link

Fluid Wrap Panel: changing the drag "grip" area #12

Closed jasonwurzel closed 6 years ago

jasonwurzel commented 6 years ago

Hi,

you have implemented a very nice library here, congratulations! One question I have regarding the FluidWrapPanel: In its default implementation, the FluidPointerDragBehavior triggers, no matter where the user clicks on the control. Is there any reasonable possibility, without changing the FluidPointerDragBehavior implementation, to attach the behavior to a child control of the single items, so the drag operation triggers only if the user clicks on this child control, like a grip? I played a bit with the FluidItemControl in the SampleGallery.sln and changed it as follows, but when dragging I get a System.Collections.Generic.KeyNotFoundException.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
    </Grid.RowDefinitions>
        <Border x:Name="fillBorder"
                Margin="1"
                Background="{Binding Path=Fill, ElementName=parent}"></Border>
        <TextBlock x:Name="numText"
                   FontSize="18"
                   Foreground="White"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   Text="{Binding Path=Data, ElementName=parent}"></TextBlock>

    <Rectangle Grid.Row="1" Height="30" Fill="Red">
        <Interactivity:Interaction.Behaviors>
            <controls:FluidPointerDragBehavior DragButton="MouseLeftButton"></controls:FluidPointerDragBehavior>
        </Interactivity:Interaction.Behaviors>
    </Rectangle>
</Grid>
ratishphilip commented 6 years ago

Thanks for reporting this issue. Let me check.

jasonwurzel commented 6 years ago

Hi,

I created a PR for this (my first one ever, it was about time :-) )

https://github.com/ratishphilip/CompositionProToolkit/pull/13

I didn't take into account/test the ListViewItem case. But I think it should work.

ratishphilip commented 6 years ago

Hi Jason,

Sorry for the delay in response. I have looked at the issue and found out the cause of this problem. Though I will be rejecting your pull request, I shall be incorporating the changes you require (in a little different way).

I hope to release the update this week.

Regards, Ratish

ratishphilip commented 6 years ago

Hi @jasonwurzel

This has been fixed in the v0.8 release. Now it is possible to attach the behavior to a child control of the single items, so the drag operation triggers only if the user clicks on this child control, like a grip.

jasonwurzel commented 6 years ago

Hey @ratishphilip ,

thanks for the reply. I haven't had time to look into it but I'm curious as to how you implemented/fixed it.

ratishphilip commented 6 years ago

@jasonwurzel I had to rewrite the FluidPointerDragBehavior class and some minor modification in the FluidWrapPanel. The element to which the behavior is attached will raise the Pointer events, but the position is calculated w.r.t. the ancestor of the element which is also the child of the FluidWrapPanel.