【发布时间】:2018-11-11 04:36:26
【问题描述】:
WPF 数据模板规范中的额外行
这似乎是微软对 WPF 数据绑定的一个非常好的概述:https://docs.microsoft.com/en-us/dotnet/framework/wpf/data/data-binding-overview
该页面包含指向 PDF 下载的链接(看起来比页面本身更全面):https://docs.microsoft.com/en-us/dotnet/opbuildpdf/framework/wpf/data/toc.pdf?branch=live 和示例应用程序:http://go.microsoft.com/fwlink/?LinkID=163703。
问题:
在示例应用程序文件中:DataBindingLabApp.xaml(~ 第 50 行) 为各个列表项定义了一个数据模板。模板指定了 4 行,但只使用了 2 行...是否有充分的理由保留未使用的行?
<DataTemplate DataType="{x:Type src:AuctionItem}">
<Border BorderThickness="1" BorderBrush="Gray"
Padding="7" Name="border" Margin="3" Width="500">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/> <!-- not needed? -->
<RowDefinition/> <!-- not needed? -->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
...
我删除了 2 行,据我所知(通过比较屏幕截图),额外的行对列表项的外观没有影响。有什么理由应该保留它们吗?我唯一能想到的是一些未来的功能(但这似乎是一种糟糕的做法,不是吗?)
【问题讨论】:
-
这么多细微差别,有时很难知道是什么......
标签: c# wpf datatemplate