【发布时间】:2015-08-10 10:04:15
【问题描述】:
我需要绑定到附加属性,如 Grid.Row 和 Grid.Column,但它似乎不起作用。 我尝试了多个选项,但没有运气,下面是 xaml 详细信息。
<Grid>
<Grid>
<Grid vm:GridHelper.RowCount="{Binding RowCount}"
vm:GridHelper.ColumnCount="2" />
<ItemsControl ItemsSource="{Binding ControlCollection}">
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Grid.Row" Value="{Binding Path=Row}" />
<Setter Property="Grid.Column" Value="{Binding Path=Column}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}" Margin="5,5,20,5" FontSize="12"
TextWrapping="WrapWithOverflow"
Foreground="#AEAEAE" FontFamily="Tahoma" VerticalAlignment="Center"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
【问题讨论】:
标签: c# wpf c#-4.0 datatemplate