内容未在视图框中居中,鼠标坐标在视图框中不正确

问题描述 投票:0回答:1

[嗨,我正在尝试将应用程序移植到具有uno平台的android。我在android中有一个奇怪的行为,以下代码在为测试创建的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}";

        }

可能是我缺少某些东西,还是可能有错误?

get viewbox uno-platform
1个回答
0
投票

ruler,

© www.soinside.com 2019 - 2024. All rights reserved.