I have a TextBox and a Button in my view.
Now I am checking a condition upon button click and if the condition turns out to be false, displ
Nobody seems to have included the final step to make it easy to update attributes via binded variables. Here's what I came up with. Let me know if there is a better way of doing this.
XAML
ViewModel
public class LoginModel : ViewModelBase
{
public string txtLabel_IsFocused { get; set; }
public string butEdit_IsEnabled { get; set; }
public void SetProperty(string PropertyName, string value)
{
System.Reflection.PropertyInfo propertyInfo = this.GetType().GetProperty(PropertyName);
propertyInfo.SetValue(this, Convert.ChangeType(value, propertyInfo.PropertyType), null);
OnPropertyChanged(PropertyName);
}
private void Example_function(){
SetProperty("butEdit_IsEnabled", "False");
SetProperty("txtLabel_IsFocused", "True");
}
}