在我的WPF的电网不能创建列 [英] Can't create Columns in my WPF Grid

查看:153
本文介绍了在我的WPF的电网不能创建列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的代码对我非常的非常基本WPF项目

 <窗​​口x :类=WpfApplication1.Window1
的xmlns =htt​​p://schemas.microsoft.com/winfx/2006/xaml/presentation
的xmlns:X =htt​​p://schemas.microsoft。 COM / WinFX的/ 2006 / XAML
标题=窗口1HEIGHT =300WIDTH =300>

<电网ShowGridLines =真>
< ColumnDefinition X:NAME =LeftColumn>< / ColumnDefinition>
< /网格和GT;





但是,列定义行给我一个错误:




1时出错无法添加类型'ColumnDefinition的实例类型'UIElementCollection的集合。只有类型'的UIElement'的项目是允许的。



解决方案

您必须括在一个。ColumnDefinitions集

 <电网高度=27> 
< Grid.ColumnDefinitions>
< ColumnDefinition WIDTH =*/>
< ColumnDefinition WIDTH =*/>
< /Grid.ColumnDefinitions>
< /网格和GT;

添加行定义的作品以同样的方式。



尽情享受吧!


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:

Error 1 Cannot add instance of type 'ColumnDefinition' to a collection of type 'UIElementCollection'. Only items of type 'UIElement' are allowed.

解决方案

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.

Enjoy!

这篇关于在我的WPF的电网不能创建列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆