[英]How can I add zooming a Grid with inkCanvas and Canvas in UWP app?
I'm writing an inking UWP app in C#/XAML and would like to implement a Microsoft Whiteboard-like zooming inkCanvas and Canvas for shape/text recognition.我正在用 C#/XAML 编写一个墨迹 UWP 应用程序,并希望实现一个类似于 Microsoft Whiteboard 的缩放 inkCanvas 和 Canvas,用于形状/文本识别。 I have a Grid with an ImageBrush background with the Canvas and InkCanvas, but I'm not sure how to go about a zooming function.我有一个带有 ImageBrush 背景和 Canvas 和 InkCanvas 的网格,但我不确定如何使用缩放功能。
My code for context:我的上下文代码:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="HeaderPanel"
Orientation="Horizontal"
Grid.Row="0">
<TextBlock x:Name="Header"
Text="Basic ink analysis sample"
Style="{ThemeResource HeaderTextBlockStyle}"
Margin="10,0,0,0" />
<InkToolbar TargetInkCanvas="{x:Bind inkCanvas}"/>
<Button x:Name="recognize"
Content="Recognize"
Margin="50,0,10,0"/>
</StackPanel>
<Grid x:Name="drawingCanvas" Grid.Row="1">
<Grid.Background>
<ImageBrush ImageSource="/Assets/isoPaper.png" AlignmentY="Top" AlignmentX="Center"/>
</Grid.Background>
<!-- The canvas where we render the replacement text and shapes. -->
<Canvas x:Name="recognitionCanvas" />
<!-- The canvas for ink input. -->
<InkCanvas x:Name="inkCanvas"/>
</Grid>
</Grid>
try wrapping inkcanvas into a scrollviewer and the call tha funtion changeView(HorizontalOffset,Verticaloffset,zoomLevel) from backend尝试将 inkcanvas 包装到滚动查看器中,并从后端调用函数 changeView(HorizontalOffset,Verticaloffset,zoomLevel)
<StackPanel x:Name="HeaderPanel"
Orientation="Horizontal"
Grid.Row="0">
<TextBlock x:Name="Header"
Text="Basic ink analysis sample"
Style="{ThemeResource HeaderTextBlockStyle}"
Margin="10,0,0,0" />
<ScrollViewer x:Name="scroll">
<InkToolbar TargetInkCanvas="{x:Bind inkCanvas}"/>
</ScrollViewer>
<Button x:Name="recognize"
Content="Recognize"
Margin="50,0,10,0"/>
</StackPanel>
scroll.ChangeView(null,null,zoomLevel)
it will zoom the Ink Canvas and Provide scroll to pan it它将缩放 Ink Canvas 并提供滚动以平移它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.