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>

运行如图
控件不显示

1个回答

StackPanel 的Height 设置为20 的问题

WZG89655415
WZG89655415 谢谢,真的是这个原因啊!自己没注意到了
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐