c# - Changing Main Viewing Area -



c# - Changing Main Viewing Area -

i'm wondering how go creating different views in main window when button pressed. i'm not sure of right terminology, has hampered google fu.

i'm thinking main viewing area content control, alter when event happens. made little drawing help illustrate thought / thought.

any input appreciated. thanks!

it easy implement senario using mvvm approach....

make viewmodel mainview. define properties of viewmodels of usercontrols

for illustration have 2 usercontrol firstview , secondview create properties in viewmodels viewtoloadproperty of type viewmodel (usually called viewmodelbase)

set bindings

<!-- panel hosting usercontrols --> <border grid.column="2"> <contentcontrol name="usercontrolcontentcontrol" content="{binding path=viewtoloadproperty, }"> <contentcontrol.resources> <datatemplate datatype="{x:type viewmodellayer:firstviewmodel}"> <viewlayer:firstview/> </datatemplate> <datatemplate datatype="{x:type viewmodellayer:secondviewmodel}"> <viewlayer:secondview /> </datatemplate> </contentcontrol.resources> </contentcontrol> </border> <!-- panel hosting usercontrols -->

then when click button utilize command set respective viewmodel intance this(viewtoloadproperty) property...(use relaycommannds or it)

datatempates rest of job selecting right view according right type of viewmodel

you can utilize mvvmlight toolkit if implementing mvvm pattern.. :)

c# wpf contentcontrol

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -