Advertisement
Guest User

Untitled

a guest
May 4th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Runtime.CompilerServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace WindowsFormsApplication1
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. bindingSource1.DataSource = Class1.Instance;
  20. }
  21.  
  22. private void button2_Click(object sender, EventArgs e)
  23. {
  24. Class1.Instance.MyProperty = "Jhoiheofcjwp";
  25. }
  26. }
  27.  
  28.  
  29. public class Class1 : INotifyPropertyChanged
  30. {
  31. private Class1() { }
  32.  
  33. private static Class1 instance;
  34. public static Class1 Instance
  35. {
  36. get
  37. {
  38. if (instance == null) instance = new Class1();
  39. return instance;
  40. }
  41. }
  42.  
  43.  
  44. private string myProperty = "Hallo";
  45. public string MyProperty
  46. {
  47. get { return myProperty; }
  48. set { myProperty = value; OnPropertyChanged(); }
  49. }
  50.  
  51. public event PropertyChangedEventHandler PropertyChanged;
  52.  
  53. protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
  54. {
  55. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  56. }
  57.  
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement