c# - WPF Design-time Data Binding to Sample Data -
wpf, c#, .net 4.52, visual studio 2015, mvvm, prism/unity, telerik ui wpf - listbox "radlistbox" control
based on following class pseudo-structure gets populated database calls @ run-time:
<process>     <steps>         <step>             <submodules>                 <submodule>                 <submodule>                 <submodule>             </submodules>         </step>         <step>             <submodules>                 <submodule>             </submodules>         </step>     </steps> </process>   i have view model property called selectedstep represents current step. of type step.
i have view listbox control itemssource property bound selectedstep.submodules. works great @ runtime , shows me list of submodules selected step.
but want see list of sub modules @ design time can style list. created sample data in file called step.xaml structure looks this:
<step>     <submodules>         <submodule>         <submodule>         <submodule>     </submodules> </step>   there 1 step defined because i'm going show single step's sub modules @ design time. there's no selecting steps there @ run-time.
to able bind sample data, added following attribute listbox: d:datacontext="{d:designdata source=step.xaml}"
with listbox's itemssource="{binding selectedstep.submodules}" correct @ run-time, don't see @ design time. have change itemssource="{binding submodules}" see data @ design-time. breaks view @ run-time.
how overcome issue since selectedstep not being set @ design time?
thanks, chris
you assigning d:designdata datacontext property, have pass view model there. step.xaml should that:
<yourviewmodel>     <yourviewmodel.selectedstep>         <step>             <submodules>                 <submodule>                 <submodule>                 <submodule>             </submodules>         </step>     </yourviewmodel.selectedstep> </yourviewmodel>   then bindings should work @ runtime.
Comments
Post a Comment