【发布时间】:2016-12-03 17:55:19
【问题描述】:
在一个全新的通用 Windows 平台应用程序中,我正在尝试设置 ItemsControl 的背景。但它似乎没有做任何事情。我对 VS 模板所做的唯一更改是在 MainPage.xaml 中,现在看起来像这样:
<Page
x:Class="UWPPlayground.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWPPlayground"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" x:Name="Hello">
<Grid Background="Blue">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*">
</ColumnDefinition>
<ColumnDefinition Width="*">
</ColumnDefinition>
</Grid.ColumnDefinitions>
<ItemsControl Grid.Row="0" Grid.Column="0" Width="60" Height="30" Foreground="Wheat" Background="White">
<TextBlock Text="Hello World!"></TextBlock>
<TextBlock Text="Can you see this?"></TextBlock>
</ItemsControl>
<Grid Grid.Row="0" Grid.Column="1" Background="Purple"></Grid>
</Grid>
</Page>
结果如下所示。 ItemsControl 的 Foreground 属性似乎工作得很好,因为 TextBlocks 有小麦色的文本。由于控件的尺寸较小,文本被截断,正如预期的那样。然而,背景是不可见的。我错过了什么?
【问题讨论】:
标签: xaml background uwp itemscontrol