how do i insert a stack panel into a grid? [duplicate]
Possible Duplicate:
Can't create Columns in my WPF Grid. [Newbie]
i tried to insert the stack panel into grid using the following:
<TabItem Header ="XML PARSING" Name="Tabitem5" Visibility="Visible">
<Grid>
<ColumnDefinition/>
<ColumnDefinition/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<StackPanel Name="stack1" Grid.Row="1" Grid.Column="0">
<Button Height="23" Name="Xmlap开发者_开发问答pendButton" Width="75" HorizontalAlignment="Right" Click="XmlappendButton_Click">Update</Button>
</StackPanel>
</Grid>
</TabItem>
I can't seem to be able to load the design view after this. Any help is appreciated
EDIT:
Sorry the error is:
Error 1 A value of type 'ColumnDefinition' cannot be added to a collection or dictionary of type 'UIElementCollection'.
You are wrongly defining your columns and rows. You need to have your <ColumnDefinition />
's inside the the grid ColumnDefinitions property. You access that property through <Grid.ColumnDefinitions></Grid.ColumnDefinitions>
. Apply the same logic for rows which have to be declared inside the Grid's RowDefinitions property. Here's the corrected sample:
<TabItem Header ="XML PARSING" Name="Tabitem5" Visibility="Visible">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Name="stack1" Grid.Row="1" Grid.Column="0">
<Button Height="23" Name="XmlappendButton" Width="75" HorizontalAlignment="Right" Click="XmlappendButton_Click">Update</Button>
</StackPanel>
</Grid>
</Tabitem>
精彩评论