WZG89655415
2015-04-29 18:34
采纳率: 50%
浏览 4.8k
已采纳

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

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

    StackPanel 的Height 设置为20 的问题

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题