Created
September 29, 2015 09:11
-
-
Save voidtuxic/0441e0aaab10b926b906 to your computer and use it in GitHub Desktop.
Bindable InkCanvas for UWP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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