internal void UpdateDataSourcePropertyValue(string propertyName) { if (!listenForViewModelChanges) { return; } if (String.IsNullOrEmpty(propertyName)) { return; } var elements = xmlLayout.GetElementsForDataSource(propertyName, propertyName); if (elements.Count > 0) { object value = MVVMUtilities.GetNestedMemberValue(typeof(T), propertyName, viewModel); if (value is IObservableList) { elements.ForEach(e => e.SetListData((IObservableList)value)); } else { elements.ForEach(e => e.SetValue(value != null ? value.ToString() : null, false)); } } }
public override void ViewModelMemberChanged(string memberName) { if (!listenForViewModelChanges) { return; } // if this member is inline, then a complete rebuild is necessary if (xmlLayout.Xml.Contains("{" + memberName + "}")) { ViewModelUpdated(); return; } // otherwise, look for the element(s) using the data source string var elements = xmlLayout.GetElementsForDataSource(memberName, memberName); if (elements.Count > 0) { object value = MVVMUtilities.GetNestedMemberValue(typeof(T), memberName, viewModel); if (value is IObservableList) { elements.ForEach(e => e.SetListData((IObservableList)value)); } else { elements.ForEach(e => e.SetValue(value != null ? value.ToString() : null, false)); } } return; }
/// <summary> /// Get the value of a field or property /// </summary> /// <param name="memberName"></param> /// <returns></returns> public object GetValue(string memberName) { return(MVVMUtilities.GetNestedMemberValue(GetType(), memberName, this)); }