【发布时间】:2016-10-28 21:29:17
【问题描述】:
我有下一个 app.xaml 资源:
<LinearGradientBrush x:Key="ApplicationBackground" EndPoint="0,0" StartPoint="3,3" MappingMode="Absolute" SpreadMethod="Repeat">
<GradientStop Color="#F1F1F1" Offset="0"/>
<GradientStop Color="#F1F1F1" Offset="0.2"/>
<GradientStop Color="White" Offset="0.2"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="MenuBackground" Color="#FF01579B"/>
我创建了一个用户控件,它将作为菜单内容 - MenuController.xaml
代码如下:
<UserControl
<ScrollViewer Background="{StaticResource MenuBackground}">
</ScrollViewer>
</UserControl>
我把它放在了主页上:
<Page
<Grid Background="{StaticResource ApplicationBackground}">
<controllers:MenuController/>
</Grid>
</Page>
以及它在移动设备和 PC 上的表现:
为什么?是什么导致了这种差异以及如何解决这个问题?
这里是这种行为的更简单的场景:
<LinearGradientBrush x:Key="ParentBackground" EndPoint="0,0" StartPoint="3,3" MappingMode="Absolute" SpreadMethod="Repeat">
<GradientStop Color="#F1F1F1" Offset="0"/>
<GradientStop Color="#F1F1F1" Offset="0.2"/>
<GradientStop Color="White" Offset="0.2"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ChildBackground" Color="White"/>
在 MainPage 我有 2 个网格:
<Grid Opacity="1" Background="{StaticResource ParentBackground}">
<Grid Opacity="1" Canvas.ZIndex="10" Background="{StaticResource ChildBackground}">
</Grid>
</Grid>
内部网格是灰色的,而不是白色的! 在移动设备上一切正常
【问题讨论】:
-
MenuBackground != ApplicationBackground,您的示例代码 sn-ps 是否正确?
-
@Bart 没有理解你的问题......这里有什么不正确的?我有一个单页应用程序 - 我可以将我的主网格资源称为 Applicationbackground
-
@Bart 我找到了原因。在 PC 上,LinearGradientBrush 似乎总是在 UI 之上