Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GetPropertyNameメソッドの呼び出し
public MainViewModel()
{
strChange = new RelayCommand(StrChange);
}
public ICommand strChange
{
get; private set;
}
private string str_;
/// <summary>
/// 文字列
/// </summary>
public string Str
{
get
{
return str_;
}
set
{
if (str_ != value)
{
str_ = value;
// ここでさきほど定義したGetPropertyNameメソッドの呼び出し(戻り値がプロパティ名)
NotifyPropertyChanged(PropertyGet.GetPropertyName(()=> Str));
}
}
}
/// <summary>
/// PropertyChangedの実装
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
private void StrChange()
{
Str = "名前を取得できているからこれが表示される";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.