I have a list with InkStrokeContainer in a ListView and I try to bind the InkCanvas to it. In WPF the InkCanvas had a Strokes attribut but in UWP its not available. Another idea was to bind to an InkPresenter but how?
Then my idea was to create a InkCanvasControl which extends from InkCanvas and create the Property for the Strokes.
public InkStrokeContainer Strokes
{
get
{
return this.InkPresenter.StrokeContainer;
}
set
{
this.InkPresenter.StrokeContainer = value;
}
}
But with this I got the error: "Cannot assign property Strokes"... I used it this way:
<controls:InkCanvasControl Strokes="{Binding Strokes}"></controls:InkCanvasControl>
And the binding is from my ViewModel.
The problem here is that the
Strokes
property you've created is not a dependency property, so it won't support binding and that's why you got the error. To solve this problem, you can registerStrokes
property as a dependency property like following:For more info, please see Custom dependency properties.