我无法在UI上看到任何我的堆栈面板,Data Grid占用了所有可用的UI空间。为什么?
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="500"/>
</Grid.RowDefinitions>
</Grid>
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="Red" >
<TextBox Height="50" Width="250">t1</TextBox>
<Slider></Slider>
<TextBox>t2</TextBox>
</StackPanel>
<Grid Grid.Row="1" >
<DataGrid Name="DGComm" AutoGenerateColumns="False" CanUserResizeColumns="True" IsReadOnly="True" ItemsSource="{Binding LogMessagesList}">
<DataGrid.Columns>
<DataGridTextColumn Header="Time Stamp." Binding="{Binding Date, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss,fff}'}" Width="0.1*"/>
.
.
</DataGrid>
</Grid>
答案 0 :(得分:0)
不显示堆栈的原因 - 在将任何内容放入其中之前,您已关闭Grid标记。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="500"/>
</Grid.RowDefinitions>
</Grid>
我假设您发布了有问题的XAML。 请尝试以下代码
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="500"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="Red" >
<TextBox Height="50" Width="250">t1</TextBox>
<Slider></Slider>
<TextBox>t2</TextBox>
</StackPanel>
<Grid Grid.Row="1">
<DataGrid Name="DGComm" AutoGenerateColumns="False" CanUserResizeColumns="True" IsReadOnly="True" ItemsSource="{Binding LogMessagesList}">
<DataGrid.Columns>
<DataGridTextColumn Header="Time Stamp." Binding="{Binding Date, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss,fff}'}" Width="0.1*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Grid>