【问题标题】:How to set value to an Usercontrol inside a ListBox Item Template while loading listbox?加载列表框时如何为列表框项目模板内的用户控件设置值?
【发布时间】:2011-01-14 00:26:29
【问题描述】:

我有一个UserControl,里面有一个DependencyPropertyEmployeeSchedule,它将接受DataTableDataRow。我创建了一个Listbox,并在ItemTemplate 中提到了这个UserControl

我的问题是UserControl 的数据是它所在的ListboxItem 的当前行或DataContext。如何将ListboxItem 的数据提供给用户控件依赖属性?

谢谢

【问题讨论】:

    标签: wpf data-binding user-controls listbox itemtemplate


    【解决方案1】:
    <custom:MyUserControl EmployeeSchedule="{Binding PathToScheduleOffTheAcutalDataObject}" />
    

    确定吗?数据绑定为您提供了一种强大的方式来引用数据项上可用的属性。这可以采用简单属性名称、多级路径以及数组索引等形式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-13
      • 2011-04-04
      相关资源
      最近更新 更多