Skip to content

Instantly share code, notes, and snippets.

@sakapon
Created July 17, 2016 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakapon/7dbea5ee4b172cdc052888b2b2cf1b36 to your computer and use it in GitHub Desktop.
Save sakapon/7dbea5ee4b172cdc052888b2b2cf1b36 to your computer and use it in GitHub Desktop.
BindingSample / BindingConsole / PropertyDescriptor
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