带有usercontrol的WPF水平ItemsControl

时间:2013-04-17 07:53:33

标签: wpf user-controls itemscontrol horizontallist

我正在尝试设计UserControls的水平堆栈。我的UserControlMiniControl ObservableCollection<MiniControl>ViewModel名为MiniVideos。在Window我试图将所有内容放在一起我有这个代码:

<ItemsControl x:Name="items" Margin="5" ItemsSource="{Binding Path=MiniVideos}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal" Background="LightGray"/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>

    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <ContentPresenter />
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

当我运行代码时,它没有按预期工作,输出中出现以下错误:

  

System.Windows.Data错误:26:对于ItemsControl容器类型的项目,将忽略ItemTemplate和ItemTemplateSelector;类型= 'MiniControl'。

有什么想法吗?

0 个答案:

没有答案
相关问题