有人知道如何在SKXamlCanvas命名空间中使用SkiaSharp.Views.UWP吗?
我找到了关于SkiaSharp.Views.Forms和SKCanvasView的信息。
官方网站上有https://developer.xamarin.com/api/namespace/SkiaSharp.Views.UWP/
但是nuget对UWP一无所知。Nuget只有表格的包。
发布于 2018-02-14 13:46:09
查看SkiaSharp存储库中的GitHub中的GitHub。
他们使用Canvas的方式如下:
<Page
x:Class="SkiaSharpSample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SkiaSharpSample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:skia="using:SkiaSharp.Views.UWP"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<skia:SKXamlCanvas PaintSurface="OnPaintSurface" />
</Grid>
</Page>重要的是使用SkiaSharp.Views.UWP属性导入xmlns命名空间,以便在XAML中使用它。
在您将NuGet包安装到您的UWP项目后,名称空间本身应该是可用的。请注意,您只能从UWP项目访问SKXamlCanvas,而不能从共享类库访问。
如果您使用SkiaSharp.Forms,情况就会有所不同。您不直接使用SKXamlCanvas。相反,库在共享库中使用SkiaSharp.Views.Forms.SKCanvasView,然后使用Xamarin.Forms自定义呈现器在UWP上将此视图呈现为SKXamlCanvas (参见这里的源代码)。基本上,您不应该直接使用SKXamlCanvas,而是使用SKCanvasView。
https://stackoverflow.com/questions/48788486
复制相似问题