WZG89655415
WZG89655415
采纳率50%
2015-04-29 18:34 阅读 4.6k
已采纳

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条回答 默认 最新

  • 已采纳
    u012884462 kxmytyy 2015-04-30 02:39

    StackPanel 的Height 设置为20 的问题

    点赞 评论 复制链接分享

相关推荐