Re: Use MultiBinding to bind polyline point to a thumb

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Jobson

    Re: Use MultiBinding to bind polyline point to a thumb

    >I have a sample similar to a previous post where I was binding a line end
    >to a thumb. now I'm trying to bind a polyline point to a thumb. in this
    >case its the first point, but later it could be any point which I will want
    >to do. In this sample I'm not getting errors, but the binding doesn't seem
    >to be doing anything. In the custom polyline class I created a new dp
    >property called FirstPoint which is Points[0] of the polyline's point
    >collection and I bound this dp to the center of the thumb. It seems like
    >it should be working, but doesnt. Can anyone explain why? I attached a
    >very simple and small project demonstraightin g this.
    Not sure if I'm right, but I think the problem is that the data binding
    doesn't go through the property wrapper, but just calls SetValue directly -
    so you're never actually changing Points[0]. The solution is to use a
    PropertyChanged Callback:

    public static readonly DependencyPrope rty FirstPointPrope rty =
    DependencyPrope rty.Register("F irstPoint",
    typeof(Point), typeof(ArrowPol yline),
    new FrameworkProper tyMetadata(new Point(),
    FrameworkProper tyMetadataOptio ns.AffectsMeasu re,
    MyCallback));

    public static void MyCallback(Depe ndencyObject d,
    DependencyPrope rtyChangedEvent Args e)
    {
    ArrowPolyline ap = (ArrowPolyline) d;
    ap.Points[0] = (Point)e.NewVal ue;
    }

    Chris Jobson


Working...