Created
July 17, 2016 10:10
-
-
Save sakapon/7dbea5ee4b172cdc052888b2b2cf1b36 to your computer and use it in GitHub Desktop.
BindingSample / BindingConsole / PropertyDescriptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel; | |
namespace BindingConsole | |
{ | |
class Program | |
{ | |
[STAThread] | |
static void Main(string[] args) | |
{ | |
var person = new Person0 { Id = 123, Name = "Taro" }; | |
var properties = TypeDescriptor.GetProperties(person); | |
var nameProp = properties[nameof(person.Name)]; | |
nameProp.AddValueChanged(person, (o, e) => Console.WriteLine(person.Name)); | |
nameProp.SetValue(person, "Jiro"); // 出力: Jiro | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment