LayoutAnchorablePane绑定到项目

时间:2015-07-31 12:58:44

标签: c# wpf

我正在尝试使用LayoutAnchorablePane并在窗口中添加窗格子项,如下所示

<ad:LayoutAnchorablePane DockHeight="Auto" x:Name="LeftTools">
</ad:LayoutAnchorablePane>

在后面的代码中我添加了它的子项

dockSite = new LayoutAnchorable();
LeftTools.Children.Add((LayoutAnchorable)dockSite);

有没有办法绑定它?我在我的VM中完成了这个

// In Constructor
ObservableCollection<LayoutAnchorable> LeftToolList = new ObservableCollection<LayoutAnchorable>();

// Property
public ObservableCollection<LayoutAnchorable> LeftToolList { get; set; }

但是如何绑定到xaml?

1 个答案:

答案 0 :(得分:0)

使用ItemsControl显示收藏中的项目,但告诉它使用哪种面板类型。

<ItemsControl ItemsSource="{Binding LeftToolList}">
   <ItemsControl.ItemsPanel>
      <ItemsPanelTemplate>
         <ad:LayoutAnchorablePane/>
      </ItemsPanelTemplate>
   </ItemsControl.ItemsPanel>
</ItemsControl>