如何将堆栈面板插入网格中?
可能的重复:
无法在我的 WPF 网格中创建列。 [新手]
我尝试使用以下命令将堆栈面板插入网格中:
<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="XmlappendButton" Width="75" HorizontalAlignment="Right" Click="XmlappendButton_Click">Update</Button>
</StackPanel>
</Grid>
</TabItem>
此后我似乎无法加载设计视图。感谢任何帮助
编辑: 抱歉,错误是: 错误 1 “ColumnDefinition”类型的值无法添加到“UIElementCollection”类型的集合或字典中。
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="XmlappendButton" 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'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您错误地定义了列和行。您需要将
放在网格 ColumnDefinitions 属性内。您可以通过
访问该属性。对必须在 Grid 的 RowDefinitions 属性内声明的行应用相同的逻辑。这是更正后的示例: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: