c# - Repeating control n times and binding each instance -


i trying figure out less messy way of repeating control n times, depending on bound model's property value. first m of n controls should displayed differently however, whereas m bound different property of viewmodel. illustrate problem, consider having viewmodel (n being display , m checked here):

public class myviewmodel : viewmodelbase {     public int display { get; set; }     public int checked { get; set; }     /* ... */ } 

for display = 5, checked = 3, view should render along lines of:

(x) (x) (x) ( ) ( ) 

each (x) , ( ) should instances of same child view type. now, when user clicks on fifth (last) control, checked should set 5 , view display

(x) (x) (x) (x) (x) 

now achieve hooking few event handlers , programmatically adding , binding ( ) instances whenever display changes. wonder though if there more concise, lessy messy method achieve this.

think of viewmodel model of view. if want show collection of items in view have provide collection on viewmodel.

in case add collection viewmodel changes when value display , checked changes. bind itemscontrol collection , provide itemtemplate items.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -