Windows phone 7 RowDefinition Height的行为差异=";“自动”;在WP7和WP8之间使用空文本块
我在ItemsControl中使用了一个DataTemplate,该控件有一个包含3行的网格:Windows phone 7 RowDefinition Height的行为差异=";“自动”;在WP7和WP8之间使用空文本块,windows-phone-7,windows-phone-8,windows-phone,Windows Phone 7,Windows Phone 8,Windows Phone,我在ItemsControl中使用了一个DataTemplate,该控件有一个包含3行的网格: <Grid Margin="12,0,0,4"> <Grid.ColumnDefinitions> <ColumnDefinition Width="80" /> <ColumnDefinition Width="330" /
<Grid Margin="12,0,0,4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="330" />
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding Due}"
Foreground="CornflowerBlue"
FontSize="28"
HorizontalAlignment="Center" />
<TextBlock Text="{Binding Expected.Value}"
Foreground="Red"
FontSize="16"
Grid.Row="1"
Grid.RowSpan="2"
HorizontalAlignment="Center" />
<TextBlock Text="{Binding Destination}"
Grid.Column="1"
FontSize="28"
TextWrapping="Wrap"
HorizontalAlignment="Left" />
<TextBlock Text="{Binding Via}"
Grid.Column="1"
Grid.Row="1"
Foreground="Gray"
FontSize="16"
HorizontalAlignment="Left" />
<TextBlock Text="{Binding Status}"
Grid.Column="1"
Grid.Row="2"
FontSize="16"
HorizontalAlignment="Left" />
<TextBlock Text="{Binding Platform.Value}"
Grid.Column="2"
Grid.RowSpan="3"
FontSize="40"
VerticalAlignment="Top"
HorizontalAlignment="Center" />
</Grid>
在某些项上,Via绑定将有一个空字符串,而在WP7上,会导致中间行折叠。但是当我将项目转换为WP8时,行为就不同了,我得到一个空行,好像它为textblox保留了空间,即使它没有文本
在这种情况下,如何强制WP8具有与WP7相同的行为?Gustavo
虽然我没有遇到同样的问题,但我可以向您保证,WP7和WP8偶尔会表现出不同的行为
在这种特殊情况下,您可能希望在textbox上有一个可见性转换器,该转换器将根据绑定文本的内容切换可见性
这里有一个同样的解决方案