简单的问题!
我想在扩展器和包含文本框的网格中提供一个itemscontrol。我想多次这样做,所以我将它包装在ControlTemplate中。
<ControlTemplate x:Key="ArrayPresenter">
<Expander Template="{StaticResource ArrayTemplate}">
<Grid>
<ContentPresenter/>
<TextBlock FontWeight="Bold" Text="Empty" Margin="3" HorizontalAlignment="Center" Foreground="#66C9C9C9" FontSize="15" Visibility="{quickConverter:Binding '$P.Count == 0 ? Visibility.Visible : Visibility.Collapsed', P={Binding Array}}" />
</Grid>
</Expander>
</ControlTemplate>
这就是我想要呈现的内容。不幸的是,只要将一个项目添加到itemscontrol,就没有任何反应,并且它不会显示新项目!
<ContentControl Template="{StaticResource ArrayPresenter}">
<ItemsControl Style="{StaticResource ArrayItemsStyle}" Margin="5" ItemTemplate="{StaticResource StructureFieldTemplate}"/>
</ContentControl>
答案 0 :(得分:1)
如评论中所述,您需要定位ControlTemplate
<ControlTemplate ... TargetType="{x:Type ContentControl}">
没有ControlTemplate
目标System.Windows.Controls.Control
类型且没有Content
来呈现,因此ContentPresenter
不知道要显示什么。