English
Summary
Conclusions
Data binding, styles, and templates separate the look from the data. In the MVVM pattern, the View binds to the properties and commands of the ViewModel, which knows nothing about the interface and is covered by unit tests, while CommunityToolkit.Mvvm removes boilerplate code.
Self-check questions
- What are the binding target and source? How is
DataContextinherited? - What happens if a binding path is wrong? How do you find such an error?
- How do the
OneWay,TwoWay,OneTime, andOneWayToSourcemodes differ? - How do you implement
INotifyPropertyChanged? What are[CallerMemberName]andSetPropertyfor? - How do
StringFormat,FallbackValue,TargetNullValue, and a value converter differ? - Why is
ObservableCollection<T>used for lists? What is aDataTemplate? - How do you sort, filter, and group items with
ICollectionView? - How does
StaticResourcediffer fromDynamicResource? How do you switch the visual theme? - What are an implicit style,
BasedOn,Trigger, andDataTrigger? - What are
ControlTemplate,TemplateBinding, andContentPresenterfor? - How does
INotifyDataErrorInfowork, and how do you show a validation error in the interface? - What roles do the Model, View, and ViewModel play? What advantages does the MVVM pattern give?
- What members does
ICommandconsist of? When isCanExecuteChangedraised? - What do
[ObservableProperty]and[RelayCommand]generate? Why must the class bepartial? - How do you test a ViewModel, and why is it placed in a separate library?
Useful links
- Data binding: https://learn.microsoft.com/dotnet/desktop/wpf/data/
- Binding diagnostics: https://learn.microsoft.com/visualstudio/xaml-tools/xaml-data-binding-diagnostics
- MVVM Toolkit: https://learn.microsoft.com/dotnet/communitytoolkit/mvvm/