[嗨,我正在尝试将应用程序移植到具有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}";
}
可能是我缺少某些东西,还是可能有错误?
ruler,