【发布时间】:2016-04-06 17:13:30
【问题描述】:
我的 ViewModel 如下所示:
public class MainViewModel : BaseViewModel
{
public List<Paragraph> Paragraphs { get; set; }
. . .
}
public class Paragraph
{
public List<ParagraphElement> Elements;
. . .
}
我的 XAML 看起来像这样:
<StackPanel Grid.Row="1">
<ItemsControl ItemsSource="{Binding Paragraphs}">
<ItemsControl ItemsSource="{Binding Elements}" ItemTemplate="{StaticResource ParagraphElements}" />
</ItemsControl>
</StackPanel>
我收到以下错误: "XamlParseException"
以及附加信息: '向'System.Windows.Controls.ItemCollection'类型的集合添加值 抛出异常。'
如何在 XAML 中绑定这个嵌套结构?
【问题讨论】:
标签: c# .net wpf xaml data-binding