c# - 某些设备的 UWP 中的 XAML 梯度问题

标签 c# xaml win-universal-app windows-10-universal

我正在使用 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]

运行应用程序时,此页面在 MPC 上呈现良好,但在 T 上呈现 Gradient和两个 Button底部的 s 根本没有渲染。我没有看到它们,但我可以按 Button s 和他们的点击事件处理程序将罢工。但如果我评论 Rectangle使用渐变,在所有设备上一切都很好。

这是应用在使用渐变时在 T 上的外观。没有按钮。而且渐变也是不可见的。 With gradient

这是应用在没有渐变的 T 上的样子。按钮到位。 Without gradient

这就是它在 PC 上运行时的样子。按钮和渐变是可见的。 This is how it should look

我在运行应用程序时没有看到任何输出错误。我不知道为什么这只发生在特定设备上。也许这是一种已知问题?

更新 1

根据用户反馈,我可以说这个错误只影响 Atom 驱动的设备。但我不确定这是否对所有 Atom 驱动的设备都是 100% 正确。

更新 2

我已使用 Insider Preview Fast Ring 中的 W10 更新了 T。错误就位。所以这与操作系统构建无关。

更新 3

切换 Button s Style恢复正常并不能解决这个问题。所以Style很好,不是原因。

最佳答案

尝试删除 Grid.RowSpan="2"来自 Rectangle (或添加 RowDefinition ),您有 4 行(4 RowDefinition )但带有 RectangleGrid.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/

相关文章:

xaml - CustomButton_123509716 targetType 与元素的类型不匹配 CustomButton_096728

xaml - 在 ContentControl 的 ContentPresenter 上覆盖元素

c# - 如何在不引用数组的情况下更改数组对象?

C#如何连接WPF和SQLITE数据库最简单的方法

c# - 如何在 C# 中使用 WebClient 下载文件并触发事件处理程序并支持超时属性?

c# - 我不想在按钮边缘看到虚线

c# - 有没有可以自动清理 GlobalSuppressions.cs 的工具?

win-universal-app - 桌面应用中的 UWP 限制

c# - 在 Windows Phone 8.1 中动态创建按钮

windows-runtime - 如何在 Windows Phone 8.1(非 Silverlight 应用程序)中使用 Pivot 控件