【问题标题】:Binding a list of controls to a canvas将控件列表绑定到画布
【发布时间】:2009-10-13 14:45:29
【问题描述】:

是否可以将标签或 FrameworkElement 的 OvservableCollection 绑定到画布? 如果可以,如何实现?

【问题讨论】:

  • “绑定”是什么意思?你想让这些物品成为孩子吗?还是您希望他们“共享”某些属性?还是别的什么?

标签: wpf binding canvas


【解决方案1】:

您可以使用 ItemsControl 并将其 ItemsPanel 属性设置为 Canvas:

<ItemsControl ItemsSource={Binding Items}>
  <ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
      <Canvas/>
    </ItemsPanelTemplate>
  </ItemsControl.ItemsPanel>
</ItemsControl>

希望有帮助

【讨论】:

    猜你喜欢
    • 2011-08-06
    • 1970-01-01
    • 2016-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-11
    相关资源
    最近更新 更多