问题描述
- wpf中添加控件怎么不显示
-
新人求指导,代码如下,TextBlock和Button不显示<Window x:Class="计算器界面.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="计算器" Height="322" Width="228"> <Grid> <StackPanel Height="20" Orientation="Vertical" VerticalAlignment="Top"> <Grid Height="20"> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <TextBlock Text="查看(V)" Grid.Column="0" VerticalAlignment="Center" Margin="5,0"></TextBlock> <TextBlock Text="编辑(E)" Grid.Column="1" VerticalAlignment="Center" Margin="5,0"></TextBlock> <TextBlock Text="帮助(H)" Grid.Column="2" VerticalAlignment="Center" Margin="5,0"></TextBlock> </Grid> <Grid Height="270"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <TextBlock Name="txtBkResult" Grid.Row="0" Grid.RowSpan="2" Grid.ColumnSpan="5"></TextBlock> <Button Name="btnMC" Content="MC" Grid.Row="2" Grid.Column="0" Background="Blue"></Button> </Grid> </StackPanel> </Grid> </Window>
解决方案
StackPanel 的Height 设置为20 的问题
时间: 2024-10-29 14:04:38