Featured post
wpf - XAML MVVM Multibinding -
i have mvvm wpf application, has 'user settings' injected view. these settings contain things last used search terms, or column widths on datagrids etc. works nicely , viewmodel unaware of these settings view specific , viewmodel may shared multiple views.
these values bound in xaml of view.
however, of settings have level of interference properties on viewmodel.
an example:
viewmodel has property of public int maxresults { get; set; }
used limit number of results query brings back.
when user changes value from, say, 100 50, ideally want saved in view's settings; enabling next time view used value 50 used rather 100.
my first question:
how can bind both view settings, , viewmodel property same element? thinking multi value converter, unsure of whether there funkier ways of performing operation. need both bindings 2 way, not horrible update loops.
my second question:
sometimes i'll want viewmodel take precedence on values supplied view settings. i'm wondering if has suggestions allowing 1 bound value take precendence on another.
any comments / answers / questions appreciated.
i don't see point in having viewmodel ignorant of these settings. i'd have vm in control of these user preferences , have view pick them via binding.
this has advantage of having control of these prefs view model , can test user preferences being loaded correctly in vm via unit tests.
remember, vm view on model having user preferences loaded via vm makes perfect sense here , less have edge-cases these.
- Get link
- X
- Other Apps
Comments
Post a Comment