当前位置:网站首页>win10 uwp InkCanvas控件数据绑定
win10 uwp InkCanvas控件数据绑定
2022-08-07 14:50:00 【林德熙】
本文主要说如何绑定InkCanvas,让笔画变化的时候我们可以知道。
我们本来的InkCanvas没有提供笔画绑定,所以我们自己写
using Windows.UI.Input.Inking;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
public static class InkCanvasBinder
{
public static InkStrokeContainer GetInkStrokes(DependencyObject obj) =>
obj.GetValue(InkStrokesProperty) as InkStrokeContainer;
public static void SetInkStrokes(DependencyObject obj, InkStrokeContainer value) =>
obj.SetValue(InkStrokesProperty, value);
public static DependencyProperty InkStrokesProperty = DependencyProperty.RegisterAttached(
"InkStrokes", typeof(InkStrokeContainer), typeof(InkCanvasBinder),
new PropertyMetadata(null, InkStrokesProperty_PropertyChanged));
private static void InkStrokesProperty_PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var inkCanvas = d as InkCanvas;
if (inkCanvas != null) inkCanvas.InkPresenter.StrokeContainer = e.NewValue as InkStrokeContainer;
}
}我们使用InkCanvas
<InkCanvas local:InkCanvasBinder.InkStrokes="{x:Bind AnInkStrokeContainer}" />参见:https://github.com/Microsoft/Windows-task-snippets/blob/master/tasks/InkCanvas-data-binding.md
边栏推荐
猜你喜欢

LeetCode HOT HOT 100 (9. Telephone number letter combinations)

线程的控制与同步
![[HCIP] Small Experiment on BGP Routing Problem](/img/a2/68221545ad7bf2df7ca6edabacc27d.png)
[HCIP] Small Experiment on BGP Routing Problem

基于RK3566中RTL8201F网口百兆调试笔记

Hash table | The sum of three numbers, the sum of four numbers | The most suitable `double pointer method` | leecode brush notes
![[Principle of Database System] Chapter 4 Advanced Database Model: E/R Model and Its Design Rules and Constraints](/img/67/c6ee5068487bb812c8092fce7ad81c.png)
[Principle of Database System] Chapter 4 Advanced Database Model: E/R Model and Its Design Rules and Constraints

Solidigm officially launches PCIe 4.0 solid state drive Solidigm P41 Plus

Chapter 8 C programming expert why programmers cannot distinguish where Halloween and Christmas 8.5 prototype fail

C Expert Programming Chapter 7 Thinking About Memory 7.8 Take it easy --- "Thing King" and "Page Game"

【通信原理】第四章 -- 信道
随机推荐
文件管理:文件存储空间管理
X64 assembly language instruction encoding
LeetCode 热题 HOT 100(6.正则表达式匹配)
云信小课堂 | 基于 NERoom 快速实现在线会议
RPG游戏地图场景管理维护(服务器)
自动化测试、测试左移、精准测试,一次性说透
LeetCode Hot Questions HOT 100 (6. Regular Expression Matching)
dotnet 线程静态字段
Programming Experts in C Chapter 8 Why Programmers Can't Tell the Difference Between Halloween and Christmas 8.4 The Pain of Prototypes
亚马逊云科技 Build On 参与心得
up to date!A summary of all Kaggle competition open source solutions and Top ideas, a total of 477 competitions!
Visual studio 创建项目失败vstemplate
联盛德W801系列4-MQTT使用
国内软件测试岗,可以卷到什么程度?
dotnet 通过 WMI 拿到显卡信息
03 【常用类型(下)】
【电工学(下)】部分基础概念整理
使用通达信炒股,资金能保证安全吗?
(imdb数据集)电影评论分类实战:二分类问题
做一个物联网云平台到底要多少钱?