binding - WPF DataTemplate for Collection -
i must hang head, have scoured google hours , still have no clue i'm doing wrong.
<datatemplate datatype="{x:type local:controllers}"> <listbox> <listbox.itemtemplate> <datatemplate> <wrappanel> <textblock text="{binding path=port}" /> </wrappanel> </datatemplate> </listbox.itemtemplate> </listbox> </datatemplate>
what i'm trying display arbitrary number of controller objects in list. "controllers" alias "list<controller>". "port" property of each "controller" object, of course of study that's not showing on list. items beingness correctly added collection list based on (the collection stored content property of contentcontrol displaying collection of objects), no item in collection beingness displayed.
i thought @ first might update issue--that collection beingness correctly displayed in initial, empty state, isn't case; if start collection populated, still no items.
help me, obi wan. :(
you need bind listbox
. {binding}
, refers instance of datatemplate
s datatype
passed in @ run-time.
<datatemplate datatype="{x:type local:controllers}"> <listbox itemssource="{binding}"> <listbox.itemtemplate> <datatemplate> <wrappanel> <textblock text="{binding path=port}" /> </wrappanel> </datatemplate> </listbox.itemtemplate> </listbox> </datatemplate>
wpf binding collections datatemplate
No comments:
Post a Comment