GridSplitterApp icon indicating copy to clipboard operation
GridSplitterApp copied to clipboard

Support UWP

Open QuentinDosSantos opened this issue 6 years ago • 9 comments

Hi, Your GridSplitter is exactly what i need, unfortunatly UWP is not supported. Is there a simple way to change winphone to uwp ?

QuentinDosSantos avatar Mar 22 '19 12:03 QuentinDosSantos

I think so yes. What are you trying to build exactly?

andreinitescu avatar Mar 22 '19 12:03 andreinitescu

My application is on Android and UWP, and i have two view on a page, the user want to expand one view to see all the information in this view

QuentinDosSantos avatar Mar 22 '19 12:03 QuentinDosSantos

Do you need to actually drag the splitter?

andreinitescu avatar Mar 22 '19 12:03 andreinitescu

Yes

QuentinDosSantos avatar Mar 22 '19 12:03 QuentinDosSantos

A very simple solution is to use a custom renderer for UWP, because Grid is available on UWP. YOu need to figure how to get the XF views in the UWP Grid control. Or, if you can wait few weeks (around 2 weeks ) I have a better solution

andreinitescu avatar Mar 22 '19 13:03 andreinitescu

I can wait. Thank you for your answer

QuentinDosSantos avatar Mar 22 '19 13:03 QuentinDosSantos

I ported the WinPhone renderer to the following UWP code. Seems to work as expected but haven't done any thorough testing

public class GridSplitterRenderer : VisualElementRenderer<GridSplitter, Control>
{
    private Point? _lastPt;

    protected override void OnElementChanged(ElementChangedEventArgs<GridSplitter> e)
    {
        if (e.OldElement != null)
        {
            PointerPressed -= GridSplitterRenderer_PointerPressed;
            PointerReleased -= GridSplitterRenderer_PointerReleased;
            PointerMoved -= GridSplitterRenderer_PointerMoved;
        }

        if (e.NewElement != null)
        {
            PointerPressed += GridSplitterRenderer_PointerPressed;
            PointerReleased += GridSplitterRenderer_PointerReleased;
            PointerMoved += GridSplitterRenderer_PointerMoved;

        }
    }

    private void GridSplitterRenderer_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
    {
        if (_lastPt != null)
        {
            var point = e.GetCurrentPoint(null).Position;

            (Element as GridSplitter).UpdateGrid(point.X - _lastPt.Value.X, point.Y - _lastPt.Value.Y);
            _lastPt = point;
        }
    }

    private void GridSplitterRenderer_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
    {
        _lastPt = null;
    }

    private void GridSplitterRenderer_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
    {
        _lastPt = e.GetCurrentPoint(null).Position;

        this.CapturePointer(e.Pointer);
    }
}

fisboger avatar Apr 01 '19 07:04 fisboger

@QuentinDosSantos Sorry but I haven't got time to do this and I don't think I will have soon.

andreinitescu avatar Apr 17 '19 03:04 andreinitescu

thx fisboger, so far this works perfect for me. and thank you Andre, perfect work!

MichaelStgt avatar Jan 09 '20 11:01 MichaelStgt