mirror of
https://github.com/m-lamonaca/dev-notes.git
synced 2025-05-14 23:24:46 +00:00
Upload of pre-existing files
This commit is contained in:
commit
4c21152830
150 changed files with 730703 additions and 0 deletions
35
.NET/Xamarin/ViewModel.cs.md
Normal file
35
.NET/Xamarin/ViewModel.cs.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
# ViewModel.cs
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace AppName.ViewModels
|
||||
{
|
||||
class PageNameViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public MainPageViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged; // event handler to notify changes
|
||||
|
||||
public string field; // needed, if substituted by ExprBody will cause infinite loop of access with the binding
|
||||
public string Property
|
||||
{
|
||||
get => field;
|
||||
set
|
||||
{
|
||||
field = value;
|
||||
|
||||
var args = new PropertyChangedEventArgs(nameof(Property)); // EVENT: let view know that the Property has changed
|
||||
PropertyChanged?.Invoke(this, args); // Ivoke event to notify the view
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue