【问题标题】:WPF: How to join business object and DataTemplate or ControlTemplate in a CustomControlWPF:如何在 CustomControl 中加入业务对象和 DataTemplate 或 ControlTemplate
【发布时间】:2017-08-03 14:41:07
【问题描述】:

我想在 WPF 中创建一个 CustomControl,以某种方式向用户呈现一对多的项目。

为此,我创建了一个具有依赖属性ItemsSource 和依赖属性ItemsTemplate 的CustomControl。但我不知道如何将来自ItemsSource 的业务对象与DataTemplate 或ControlTemplate 连接起来,这样我就可以在MeasureOverride 中测量WPFy 并将其放置在ArrangeOverride 中。

我是否对每个项目使用ContentControl 之类的东西并将我的业务对象设置为DataContext?

感谢您的任何建议或任何朝着正确方向的推动。

【问题讨论】:

    标签: wpf custom-controls


    【解决方案1】:

    在对 WPF 的 ItemsControl 进行大量搜索和监视之后,我认为我必须为每个不是 DependencyObject 本身的项目使用 ContentPresenter。

    【讨论】:

      猜你喜欢
      • 2010-12-17
      • 2019-01-22
      • 1970-01-01
      • 1970-01-01
      • 2013-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多