0

I am trying to bind the points of a polyline in control template. The points should bind to a point collection in the codebehind. My current xaml code is as follows:

<Style TargetType="{x:Type c:LineDragThumb}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type c:LineDragThumb}">
                <Polyline Stroke="Transparent" Points="{Binding}"
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Should I need to make a dependency property to hold the point collection?

Please guide..

1 Answers1

0

No, you can have simple Notifiable property of PointCollection in your code-behind for binding but make sure you implement INotifyPropertyChanged to refresh the bindings on UI.

public PointCollection Points { get; set; }

And to bind on xaml you can do like this -

<Polyline Stroke="Transparent" Points="{Binding Points,
       RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}"/>
Rohit Vats
  • 79,502
  • 12
  • 161
  • 185