Can#39;t create Columns in my WPF Grid(无法在我的 WPF 网格中创建列)
问题描述
我的非常非常基本 WPF 项目的代码.
I have this code for my very very basic WPF Project.
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid ShowGridLines="True">
<ColumnDefinition x:Name="LeftColumn"></ColumnDefinition>
</Grid>
但是,列定义行给了我一个错误:
However, the column definition line gives me an error:
错误 1 无法将ColumnDefinition"类型的实例添加到UIElementCollection"类型的集合中.只允许使用UIElement"类型的项目.
Error 1 Cannot add instance of type 'ColumnDefinition' to a collection of type 'UIElementCollection'. Only items of type 'UIElement' are allowed.
推荐答案
你必须将它包含在一个 ColumnDefinitions 集合中.
you have to enclose it in a ColumnDefinitions collection.
<Grid Height="27">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
添加行定义的工作方式相同.
Adding row definitions works the same way.
享受吧!
这篇关于无法在我的 WPF 网格中创建列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法在我的 WPF 网格中创建列


基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01