c# - WPF disabling the window close button via MVVM -
i trying disable close button on window via mvvm
i realise can in view (window) cs code stating
public window() { initializecomponent(); this.closing += new system.componentmodel.canceleventhandler(window_closing); } void window_closing(object sender, system.componentmodel.canceleventargs e) { e.cancel = true; } however maintain consistent , seek mvvm.
thanks
change closing method variable viewmodel.
void window_closing(object sender, system.componentmodel.canceleventargs e) { e.cancel = (this.datacontext myviewmodel).processworking; } in viewmodel (myviewmodel) add together property processworking :
public boolean processworking { { homecoming this.processworking; } } and in method of background thread, modify processworking
private boolean processworking; private void mybackgroundthread() { this.processworking = true; // process this.processworking = false; } you can add together raisepropertychange() when modify this.processworking if want show somewhere of ui state of background process.
c# wpf mvvm
No comments:
Post a Comment