每当我尝试将面板添加到以下网格时,边框都不会显示,带有文本的堆栈面板会消失,我不明白为什么 这是代码在我尝试向整个网格添加边框之前的样子。
<Grid Name="grdContext" Grid.Column="2" Height="Auto" Width="Auto" Margin="0" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="6*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Height="Auto" Width="Auto" HorizontalAlignment="Center" Orientation="Vertical">
<TextBlock Name="lblDate" Foreground="White" Background="Black" FontSize="14" HorizontalAlignment="Center" Margin="5,5,5,2.5">07/01/2016</TextBlock>
<TextBlock Name="lblTime" Foreground="White" Background="Black" FontSize="14" HorizontalAlignment="Center" Margin="5,2.5,5,5">14:27</TextBlock>
</StackPanel>
<Image Name="imgArchive" Grid.Row="2" Width="Auto" Height="Auto" Stretch="UniformToFill" Margin="0,0.4,10,10"/>
</Grid>
这是在
之后<Border BorderBrush="DimGray" BorderThickness="3">
<Grid Name="grdContext" Grid.Column="2" Height="Auto" Width="Auto" Margin="0" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="6*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Height="Auto" Width="Auto" HorizontalAlignment="Center" Orientation="Vertical">
<TextBlock Name="lblDate" Foreground="White" Background="Black" FontSize="14" HorizontalAlignment="Center" Margin="5,5,5,2.5">07/01/2016</TextBlock>
<TextBlock Name="lblTime" Foreground="White" Background="Black" FontSize="14" HorizontalAlignment="Center" Margin="5,2.5,5,5">14:27</TextBlock>
</StackPanel>
<Image Name="imgArchive" Grid.Row="2" Width="Auto" Height="Auto" Stretch="UniformToFill" Margin="0,0.4,10,10"/>
</Grid>
</Border>
当我走出边境时,什么都看不到?
答案 0 :(得分:0)
正如Slyvain注意到的那样,你打破了视觉树。
在您的第一个代码示例中
MainGrid
column 0 asign foo
column 1 asign fooo
column 2 asign grdContext
第二个样本
MainGrid
column 0 asign foo
column 1 asign fooo
Border?