Skip to content

Instantly share code, notes, and snippets.

@voidtuxic
Created September 29, 2015 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voidtuxic/0441e0aaab10b926b906 to your computer and use it in GitHub Desktop.
Save voidtuxic/0441e0aaab10b926b906 to your computer and use it in GitHub Desktop.
Bindable InkCanvas for UWP
using Windows.UI.Input.Inking;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
public class BindableInkCanvas : InkCanvas
{
public static readonly DependencyProperty StrokesProperty = DependencyProperty.RegisterAttached(
"Strokes",
typeof(InkStrokeContainer),
typeof(BindableInkCanvas),
new PropertyMetadata(null, StrokesChanged)
);
private static void StrokesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var instance = d as BindableInkCanvas;
if (instance != null)
{
instance.InkPresenter.StrokeContainer = instance.Strokes;
}
}
public InkStrokeContainer Strokes
{
get { return (InkStrokeContainer)GetValue(StrokesProperty); }
set { SetValue(StrokesProperty, value); }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment