简体   繁体   English

Windows Phone中的网格内的stackpanel不起作用

[英]stackpanel within grid in windows phone does not work

I tried to do this but I got message error : "ColumnDefinition does not support direct content" 我试图这样做,但我收到消息错误:“ColumnDefinition不支持直接内容”

   <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="229">
                <StackPanel Margin="0,0,0,17" Grid.ColumnSpan="2">
                    <TextBlock Height="30" Name="l1" Text="first name" />
                    <TextBox InputScope="Number" Height="71" Name="firstName" Text="" Width="460" />
                </StackPanel>
            </ColumnDefinition>
            <ColumnDefinition Width="227">
                <StackPanel Margin="0,0,0,17" Grid.ColumnSpan="2">
                    <TextBlock Height="30" Name="l1" Text="first name" />
                    <TextBox InputScope="Number" Height="71" Name="firstName" Text="" Width="460" />
                </StackPanel>                        
            </ColumnDefinition>
        </Grid.ColumnDefinitions>
    </Grid>

u cant put the content directly into the column definition, the code should---> 你不能把内容直接放到列定义中,代码应该--->

<Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="229"></ColumnDefinition>            
                <ColumnDefinition Width="227"></ColumnDefinition>   
            </Grid.ColumnDefinitions>


            <StackPanel Grid.Column="0" Margin="0,0,0,17" Grid.ColumnSpan="2">
                        <TextBlock Height="30" Name="l1" Text="first name" />
                        <TextBox InputScope="Number" Height="71" Name="firstName" Text="" Width="460" />
            </StackPanel>

             <StackPanel Grid.Column="1" Margin="0,0,0,17" Grid.ColumnSpan="2">
                        <TextBlock Height="30" Name="l1" Text="first name" />
                        <TextBox InputScope="Number" Height="71" Name="firstName" Text="" Width="460" />
             </StackPanel>   

    </Grid>

u can reference the column number, in which the specific content lies by Grid.Column = "nth Column" ex:- Grid.Column = "0" 你可以引用列号,其中具体内容由Grid.Column = "nth Column" ex: - Grid.Column = "0"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM