WPF 数据模板中的额外行
Extra rows in WPF Data Template
WPF 数据模板规范中的额外行
这似乎是来自 Microsoft 的 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 and a sample application: http://go.microsoft.com/fwlink/?LinkID=163703。
问题:
在示例应用程序文件中:DataBindingLabApp.xaml
(~ 第 50 行) 为单个列表项定义了数据模板。模板指定了 4 行,但只使用了两行...是否有充分的理由保留未使用的行?
<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 行,据我所知(通过比较屏幕截图),额外的行对列表项的外观没有影响。有什么理由应该保留它们吗?我唯一能想到的是一些未来的功能 (但这似乎是一种糟糕的做法,不是吗?)
Is there any reason they should be retained?
除非 Grid
中有任何项目将 Grid.Row
附加到 属性 到 2
或 3
,否则您可以删除它们,除非您希望前两行(仅有的两行)仅填充 Grid
总高度的 50%。
A RowDefinition
的默认高度为 Auto
,这意味着可用的 space 将平均分配给您定义的 <RowDefinition/>
个元素。
...as far as I can tell (by comparing screen shots) the extra rows make no difference to the appearance of the list items. Is there any reason they should be retained?
没有
The only thing I can think of is for some future functionality (but that seems like a poor practice, no?)
是的,那你不妨稍后再补充。
WPF 数据模板规范中的额外行
这似乎是来自 Microsoft 的 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 and a sample application: http://go.microsoft.com/fwlink/?LinkID=163703。
问题:
在示例应用程序文件中:DataBindingLabApp.xaml
(~ 第 50 行) 为单个列表项定义了数据模板。模板指定了 4 行,但只使用了两行...是否有充分的理由保留未使用的行?
<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 行,据我所知(通过比较屏幕截图),额外的行对列表项的外观没有影响。有什么理由应该保留它们吗?我唯一能想到的是一些未来的功能 (但这似乎是一种糟糕的做法,不是吗?)
Is there any reason they should be retained?
除非 Grid
中有任何项目将 Grid.Row
附加到 属性 到 2
或 3
,否则您可以删除它们,除非您希望前两行(仅有的两行)仅填充 Grid
总高度的 50%。
A RowDefinition
的默认高度为 Auto
,这意味着可用的 space 将平均分配给您定义的 <RowDefinition/>
个元素。
...as far as I can tell (by comparing screen shots) the extra rows make no difference to the appearance of the list items. Is there any reason they should be retained?
没有
The only thing I can think of is for some future functionality (but that seems like a poor practice, no?)
是的,那你不妨稍后再补充。