带有 SkiaSharp 的 UWP ScrollViewer.TopHeader 不绘图

UWP ScrollViewer.TopHeader with SkiaSharp does not drawing

我想在 ScrollViewer 中使用 SkiaSharp Canvas,但不仅在主要内容中,而且在 TopHeader 和 LeftHeader 中。调用了paint事件,skia正在绘图,但是结果没有显示在屏幕上,只是在一个主要内容中。

示例如下:

<ScrollViewer
    HorizontalScrollBarVisibility="Visible"
    HorizontalScrollMode="Enabled"
    VerticalScrollBarVisibility="Visible"
    VerticalScrollMode="Enabled">
    <ScrollViewer.TopHeader>
        <Grid
            Width="{Binding ElementName=Canvas, Path=ActualWidth}"
            Height="30"
            Background="LightGray">
            <TextBlock Text="Hello" />
            <skia:SKXamlCanvas
                x:Name="TopHeaderCanvas"
                Margin="0"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                PaintSurface="OnPaintTopHeader" />
        </Grid>
    </ScrollViewer.TopHeader>
    <ScrollViewer.LeftHeader>
        <skia:SKXamlCanvas
            Width="60"
            Height="{Binding ElementName=Canvas, Path=ActualHeight}"
            Background="Gray"
            PaintSurface="OnPaintLeftHeader" />
    </ScrollViewer.LeftHeader>
    <ScrollViewer.Content>
        <skia:SKXamlCanvas
            x:Name="Canvas"
            Width="4000"
            Height="3500"
            Margin="0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            PaintSurface="OnPaintMainContent" />
    </ScrollViewer.Content>
</ScrollViewer>

如您所见,我在 ScrollViewer 的正下方尝试了 skia sharp canvas 包裹在网格中。不幸的是,它没有帮助。

这是结果。

左边完全是空的,但应该用HotPink填充,TopHeader只显示带有"hello"的Grid,但应该被canvas覆盖,并用绿色填充.

有人知道为什么 skia 在 ScrollView TopHeader 和 Left Header 中不起作用吗?

包含 canvas 的 SkiaSharp nuget: https://www.nuget.org/packages/SkiaSharp.Views/1.68.2-preview.21

下面是一些 SkiaSharp 示例: https://github.com/mono/SkiaSharp/tree/master/samples/Basic/UWP/SkiaSharpSample

UWP ScrollViewer.TopHeader with SkiaSharp does not drawing

我可以重现你的问题,我尝试在 PaintSurface 内重新绘制 canvas 但它也不起作用,请随意 post 这个问题在 [=13] =] github,我会向团队报告此事。

这是 SkiaSharp 中的错误。 它是固定的:https://github.com/mono/SkiaSharp/pull/1133

谢谢:mattleibow