WPF绘制表格
在WPF Grid中,宽度=*
或高度=*
表示比例大小。
例如:给30%到第1列和70%到第2列 -
< ColumnDefinition Width =3 */> < ColumnDefinition Width =7 */>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | <!--WPF绘制表格并插入值--> <Grid> <!--Grid.RowDefinitions:将Grid分行--> <Grid.RowDefinitions> <RowDefinition Height= "60*" /> <RowDefinition Height= "60*" /> <RowDefinition Height= "60*" /> <RowDefinition Height= "60*" /> <RowDefinition Height= "60*" /> <RowDefinition Height= "60*" /> </Grid.RowDefinitions> <!--Grid.ColumnDefinitions:将Grid分列--> <Grid.ColumnDefinitions> <ColumnDefinition Width= "100*" /> <ColumnDefinition Width= "100*" /> <ColumnDefinition Width= "100*" /> <ColumnDefinition Width= "100*" /> <ColumnDefinition Width= "100*" /> </Grid.ColumnDefinitions> <!--Border:给需要显示的单元格画边框--> <!--Grid.ColumnSpan:占据的列数; Grid.RowSpan:占据的行数;--> <!--BorderThickness= "1" ,给BorderThickness只赋值一个值,这时候Border,上下左右边框的粗细都是1。 如果不想显示哪一边,就把那一边粗细设置为0.如BorderThickness= "0,0,1, 0" ,这时候左、上、下都不会显示,只有右边才会显示。--> <Border Grid.Row= "0" Grid.Column= "1" Grid.RowSpan= "3" Grid.ColumnSpan= "2" BorderBrush= "Chocolate" BorderThickness= "1" /> <Border Grid.Row= "0" Grid.Column= "1" Grid.RowSpan= "3" Grid.ColumnSpan= "1" BorderBrush= "Red" BorderThickness= "0,0,1,0" /> <Border Grid.Row= "0" Grid.Column= "1" Grid.RowSpan= "1" Grid.ColumnSpan= "2" BorderBrush= "Black" BorderThickness= "0,0,0,1" /> <Border Grid.Row= "1" Grid.Column= "1" Grid.RowSpan= "1" Grid.ColumnSpan= "2" BorderBrush= "Yellow" BorderThickness= "0,0,0,1" /> <Border Grid.Row= "2" Grid.Column= "0" Grid.RowSpan= "1" Grid.ColumnSpan= "2" BorderBrush= "Green" BorderThickness= "0,0,0,1" /> <!--在对应表格中填值--> <TextBlock Grid.Row= "0" Grid.Column= "1" Text= "第一行第二列" /> <TextBlock Grid.Row= "1" Grid.Column= "1" Text= "第二行第二列" /> <TextBlock Grid.Row= "2" Grid.Column= "1" Text= "第三行第二列" /> <TextBlock Grid.Row= "0" Grid.Column= "2" Text= "第一行第三列" /> <TextBlock Grid.Row= "1" Grid.Column= "2" Text= "第二行第三列" /> <TextBlock Grid.Row= "2" Grid.Column= "2" Text= "第三行第三列" /> <!--插入Textbox,同理可以插入botton--> <!--<TextBox Grid.Row= "2" Grid.Column= "2" Name= "hangsu" VerticalAlignment= "Top" BorderBrush= "Chocolate" BorderThickness= "0,0,1,0" />--> </Grid> |
https://blog.csdn.net/Dengxxxx/article/details/107542741
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战