WPF使用ItemsControl自定义ItemPanel绑定失效的问题
<Grid Grid.Row="0">
<ItemsControl
local:ScreenRowsProperty.Value="{Binding Rows}"
local:ScreenColumnsProperty.Value="{Binding Columns}"
ItemsSource="{Binding ScreenInfos}">
<ItemsControl.Template>
<ControlTemplate>
<local:DisplayScreenGrid Columns="{TemplateBinding local:ScreenColumnsProperty.Value}" IsItemsHost="True"
Rows="{TemplateBinding local:ScreenRowsProperty.Value}" />
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Gray" BorderThickness="1">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="White"
Text="{Binding Title}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
设置IsItemsHost="True"即可使用绑定,此代码相当于制定了ItemPanel为local:DisplayScreenGrid