我正在使用 Page
作为我的应用程序中的着陆屏幕。 XAML 看起来像这样:
<Grid x:Name="LayoutRoot">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="7*"/>
</Grid.RowDefinitions>
<Rectangle StrokeThickness="0" Fill="#FF79D2F4" Margin="0,0,0,-10" Grid.RowSpan="2"/>
<Rectangle StrokeThickness="0" Fill="#FF1F8CC5" Margin="0,-10,0,0" Grid.Row="2" Grid.RowSpan="2"/>
<Image Source="ms-appx:///Assets/ViewMedia/Banners/Banner_Light_Big.jpg" Grid.Row="1" Grid.RowSpan="2"/>
<Rectangle StrokeThickness="0" Grid.Row="2" Grid.RowSpan="2">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Offset="0"/>
<GradientStop Color="#7F000000" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
<StackPanel MaxWidth="300" Margin="20,35"
HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
<Button x:Name="LoginButton" x:Uid="LoginButton" Style="{StaticResource BrandButtonStyle}" Margin="0,5"
Click="LoginButton_Click"/>
<Button x:Name="RegisterButton" x:Uid="RegisterButton" Style="{StaticResource BrandButtonStyle}" Margin="0,5"
Click="RegisterButton_Click"/>
</StackPanel>
</Grid>
我有 3 台设备在运行应用程序:
- 微软 Lumia 950 XL [M]
- 定制 PC [PC]
- 联想 ThinkPad 平板电脑 2 [T]
运行应用程序时,此页面在 M 和 PC 上呈现良好,但在 T 上呈现 Gradient
和两个 Button
底部的 s 根本没有渲染。我没有看到它们,但我可以按 Button
s 和他们的点击事件处理程序将罢工。但如果我评论 Rectangle
使用渐变,在所有设备上一切都很好。
这是应用在使用渐变时在 T 上的外观。没有按钮。而且渐变也是不可见的。
我在运行应用程序时没有看到任何输出错误。我不知道为什么这只发生在特定设备上。也许这是一种已知问题?
更新 1
根据用户反馈,我可以说这个错误只影响 Atom 驱动的设备。但我不确定这是否对所有 Atom 驱动的设备都是 100% 正确。
更新 2
我已使用 Insider Preview Fast Ring 中的 W10 更新了 T。错误就位。所以这与操作系统构建无关。
更新 3
切换 Button
s Style
恢复正常并不能解决这个问题。所以Style
很好,不是原因。
最佳答案
尝试删除 Grid.RowSpan="2"
来自 Rectangle
(或添加 RowDefinition
),您有 4 行(4 RowDefinition
)但带有 Rectangle
有Grid.RowSpan=2
它加起来多达 5 行,因此可能会给您带来麻烦。
编辑:我的错,Rectangle
实际上跨越第 2 行和第 3 行 ( Grid.Row="2"
),所以没关系。
因为你只是堆叠 <StackPanel>
在 <Grid>
(没什么特别的),你可以尝试替换根布局 <Grid x:Name="LayoutRoot">
与 <Canvas x:Name="LayoutRoot">
看看这是否有所作为。
关于c# - 某些设备的 UWP 中的 XAML 梯度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35731023/