.net - Should access to controls be limited to the MainWindow class in WPF? -


in other programming languages (namely java), have created window in 1 class, , had different classes return tabs add window, when parts of window needed updated, objects didn't have passed 1 main class update controls.

however i'm new .net , see if create mainwindow.xaml, controls available in class. design, or there way access controls in class?

is better design functions return information needed update controls, or access controls in classes information needed present?

you shouldn't, in fact, putting code in code-behind bad practice.

in fact, popular way program wpf using mvvm pattern, variant of mvc.

in mvvm pattern view contains xaml or limited amount of code perform ui operations can't done using wpf's triggers , animations.

the data view provided viewmodel class through data binding. data binding provided framework , passes data , forth without view or viewmodel ever knowing other.

changes viewmodel's properties passed view framework whenever viewmodel notifies through standard interface (inotifypropertychanged).

the main difference other mvc patterns viewmodel abstraction on top of underlying business or data model, formed make work of view easier.

there no standard implementation of mvvm. 2 popular frameworks mvvm light , caliburn.micro (my preference). mvvm light more lightweight while caliburn.micro more opinionated more powerful.

as side note, ideas behind mvvm have found way few javascript frameworks backbone.js , knockout.js


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -