William Basics

Keep learning, never ending.

[WPF] How to avoid calling initial methods in the view model’s constructor

Introduction When developing a WFP application in the MVVM way, we often need to initialize such as loading data, logging, and other kinds of stuff when the view model is created. The no-brain way is to call the “initialization” method directly in the view model’s constructor while hoping the calling method never fails and finishes instantly. public class AwsomeViewModel { public AwsomeViewModel () { LoadDataFromDatabase(); } } However, To call a method that is likely to fail or costs a long time is a bad practice in any way.

[WPF] - Data Binding

Introduction 在应用了MVVM设计模式的情况下,Data Binding特别常见。因为我们需要通过它来将前后端分离,让UI的归UI,业务归业务。 所谓Dat