Col*_*tin 5 layout xaml windows-phone-8
我正在寻找1)发生了什么,以及2)如何解决问题.
问题
如果ListBox项高度高于2521,则即使将背景显式设置为其他内容,它似乎也会将背景更改为黑色.
如何再现
获取下面的示例XAML文件,并在xaml.cs文件中添加以下内容:
DataContext = new List<int>() { 1 };
Run Code Online (Sandbox Code Playgroud)
将TextBlock的高度更改为2522或更高.
示例代码不是我遇到问题的地方,但是这是一个演示错误的简单示例.我不打算有一个2522+大小的TextBlock :)
示例XAML文件
<Grid x:Name="LayoutRoot" Background="Brown">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<phone:Pivot x:Name="pivot" Title="{Binding name}" Grid.Row="1" Foreground="White" Margin="10,0,0,0">
<phone:PivotItem x:Name="mainPivot" Header="menu" Margin="0,0,20,0">
<ListBox ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Background="White">
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Height="2521" Text="some data" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontSize="22" Foreground="Purple"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</phone:PivotItem>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>
Run Code Online (Sandbox Code Playgroud)
备注
一些人对我的UI提出了担忧.上面的代码是一个示例,而不是我的实际UI.没有性能问题,ListBox也不迟缓.除了背景改变颜色外,一切都按预期工作.
不确定“为什么”,但在“什么”上,似乎网格是运行黑色背景的网格。我把网格拿出来,它的行为......
<phone:Pivot x:Name="pivot" Title="{Binding name}" Grid.Row="1" Foreground="White" Margin="10,0,0,0">
<phone:PivotItem x:Name="mainPivot" Header="menu" Margin="0,0,20,0" >
<ListBox ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28" Background="White">
<TextBlock Height="2530" Text="some data" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontSize="22" Foreground="Purple"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</phone:PivotItem>
Run Code Online (Sandbox Code Playgroud)
那对你有用吗?
| 归档时间: |
|
| 查看次数: |
1572 次 |
| 最近记录: |