我是一名长期的 WPF 设计师,但对 Windows 应用程序开发还很陌生。我正在尝试将一组对象绑定到网格上,但不断收到错误Unknown attachable member '(Grid.Row)' on element 'FrameworkElement'
和Unknown attachable member '(Grid.Column)' on element 'FrameworkElement'
.
有人可以向我解释如何通过样式设置各种网格附加属性吗?
<ItemsControl ItemsSource="{Binding}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<!-- Column and row definitions omitted for brevity -->
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="FrameworkElement">
<Setter Property="(Grid.Row)" Value="{Binding Row}" />
<Setter Property="(Grid.Column)" Value="{Binding Column}" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>