mvvm - Silverlight 4 + Prism create controls at runtime -
i'm creating silverlight 4 application manage active directory objects (crud users, groups etc). know active directory objects have lots of properties. want save groups of property names in sql db (ie, samaccountname, mail, etc.) ad object types (users, groups, etc). when user in silverlight app clicks on "create user" want to
- get property names defined in sql db user
- create pre defined silverlight control each property , add current "create view"
- be able read values user enters in controls , pass them on
the user controls differ depending on type of active directory property, i.e. property datetime value, create user control calendar. way can keep "create" views dynamic.
the silverlight / prism foundation there , i'm adding views via regionmanager. works fine i'm not sure how add controls in such dynamic way still works prism , mvvm pattern. thank input.
i'm going assume comfortable getting properties db , saving values , focus on middle area of creating view mvvm in mind.
the prism part wouldn't worry about. you've got views registered region manager , that's need do.
my initial thought how "create" controls @ runtime mvvm considered. creating controls not hard part require handle on element injecting these into, root grid example. on surface feel un-mvvm. think it's valid have "view" code done old fashion way, it's "data" code used in binding should mvvm'd. issue telling code inject controls on view inject. can't think of neat way this.
as solution not create view containing controls apply each of properties , rather "create" them when needed "hide" them when not needed? bind "visibility" property (probably through value converter) property in viewmodel can used determine if particular control should shown or not. if these placed in stack panel view dynamically shrink.
if think code example let me know.
Comments
Post a Comment