How to set value to an Usercontrol inside a ListBox Item Template while loading listbox?
-
19-09-2019 - |
Question
I have an UserControl
and inside that there is a DependencyProperty
EmployeeSchedule
which will accept a DataTable
or a DataRow
. I created a Listbox
and in the ItemTemplate
I referred to this UserControl
.
My question is that the data for the UserControl
is the currentrow or DataContext
of the ListboxItem
which it is placed. How will I supply data of the ListboxItem
to the user controls dependency property?
Thnx
Solution
<custom:MyUserControl EmployeeSchedule="{Binding PathToScheduleOffTheAcutalDataObject}" />
surely? Data Binding provides a powerful way for you to refer to properties that are available on your data item. This can take forms such as the simple property name, to multi-level paths, as well as array indexes.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow