locked
Can't get points to be implemented with bindable Objects RRS feed

  • Question

  • User395880 posted

    Hello there. I have a line of which I want to be able to change it's points based on a point list i have made. This is how my xaml looks: <Path StrokeThickness="3" Stroke="PaleGoldenrod" StrokeLineCap="Round"> <Path.Data> <PathGeometry> <PathGeometry.Figures> <PathFigureCollection> <PathFigure StartPoint="{Binding pointz}"> <PathFigure.Segments> <PathSegmentCollection> <BezierSegment Point1="{Binding pointo}" Point2="{Binding pointt}" Point3="{Binding pointth}" /> </PathSegmentCollection> </PathFigure.Segments> </PathFigure> </PathFigureCollection> </PathGeometry.Figures> </PathGeometry> </Path.Data> </Path>

    but even though it can read the binding pointo etc and can show them as a label it doesn't take them as a Point. My points derive from this class: public Point pointz { get; set; } public Point pointo { get; set; } public Point pointt { get; set; } public Point pointth { get; set; } Why is this happening? Am I missing something? Simply writing the points works but binding them seems to have no effect... Thanks in advance.

    Monday, July 27, 2020 12:42 AM

All replies

  • User369978 posted

    If you want to bind those properties , you should create bindable property , something like this

        public static readonly BindableProperty pointzProperty = 
            BindableProperty.Create("pointz", typeof(Point), typeof(Page1), null);   
    
        public Point pointz
        {
            get { return (Point)GetValue(pointzProperty); }
            set { SetValue(pointzProperty, value); }
        }
    

    Refer to

    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/bindable-properties .

    Monday, July 27, 2020 2:25 AM