user310291
user310291

Reputation: 38180

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"

   <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>

Upvotes: 0

Views: 492

Answers (1)

AKD
AKD

Reputation: 3966

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"

Upvotes: 2

Related Questions