0

您好我正在尝试将应用程序移植到具有 uno 平台的 android。我在 android 中的 viewbox 有一个奇怪的行为,以下代码在我为测试创建的 uno 应用程序的 uwp 版本中按预期工作。- 视图框内容不居中 - 鼠标位置不准确

在 MainPage.xaml

<Grid Background="#FF583793">
        <Viewbox  Stretch="Uniform" StretchDirection="Both">
            <Canvas x:Name="mainCanvas" Height="800" Width="800" Background="#FFA0ACA5" Margin="50,50,50,50" PointerPressed="UIElement_OnPointerPressed">
                <TextBlock x:Name="tblInfos" Height="64" Canvas.Left="10" Canvas.Top="10" Text="TextBlock" TextWrapping="Wrap" Width="780" FontSize="20" FontWeight="Bold"/>
                <TextBlock x:Name="tblInfos2" Height="64" Canvas.Left="10" Canvas.Top="63" Text="TextBlock" TextWrapping="Wrap" Width="780" FontSize="20" FontWeight="Bold"/>
                <Border x:Name="letter" BorderThickness="1" BorderBrush="Black" Height="200" Canvas.Left="50" Canvas.Top="300" Width="500" Background="#FF8D7E3B" HorizontalAlignment="Stretch"/>
            </Canvas>
        </Viewbox>

    </Grid>

MainPage.xaml.cs

 private void UIElement_OnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            var posCanvas = e.GetCurrentPoint(mainCanvas).Position;
            var posLetter = e.GetCurrentPoint(letter).Position;
            tblInfos.Text = $"canvas x:{posCanvas.X} y:{posCanvas.Y}";
            tblInfos2.Text = $"letter x:{posLetter.X} y:{posLetter.Y}";

        }

可能是我遗漏了什么,或者一个可能的错误?

4

2 回答 2

0

统治者,

  1. 对齐:我发现 ViewBox 与 Uno 的默认对齐方式是左上角,而它在 UWP 上居中。我为此创建了一个问题:httpsHorizontalAlignment ://github.com/unoplatform/uno/issues/2256 您可以通过指定en 来解决该问题VerticalAligment

  2. 指针位置:在计算相对于目标控件的位置时,似乎没有考虑缩放。这是我已经在 WASM 上修复的东西。我觉得在其他平台上还可以,但显然不是……我也创建了一个问题,我现在正在研究它。

于 2019-12-04T16:31:03.413 回答
0

这现在应该由这个 PR解决。它将很快在“开发”预览包中的 nuget 上可用

于 2020-01-07T00:55:16.683 回答