Ejemplo n.º 1
0
        ///<summary>Fires INotifyPropertyChanged.OnPropertyChanged for this given property Expression.
        ///Call this from a setter property to notify bindables that this property has changed.</summary>
        public void RaisePropertyChanged <T>(Expression <Func <T> > property)
        {
            MemberInfo member = MemberUtils.GetMemberInfo(property);

#pragma warning disable 0618
            OnPropertyChanged(member.Name);
#pragma warning restore 0618
            BindablePropertyAttribute attr = member.GetCustomAttribute <BindablePropertyAttribute>();
            if (attr != null && !attr.ListDependentPropertyNames.IsNullOrEmpty())
            {
                //Raise property changed on any dependent properties.
                attr.ListDependentPropertyNames.ForEach(x => RaisePropertyChanged(x));
            }
        }
Ejemplo n.º 2
0
 ///<summary>Sets the given value to the private instance of the public, bindable property. Automatically calls RaisePropertyChanged when using
 ///this method.</summary>
 protected void SetBindableProperty <T>(Expression <Func <T> > property, T value)
 {
     _dictionaryPrivateProperties[MemberUtils.GetMemberInfo(property).Name] = value;
     //Calling RaisePropertyChanged will call OnPropertyChanged for all the dependent properties.
     RaisePropertyChanged(property);
 }
Ejemplo n.º 3
0
 ///<summary>Gets the private instance of the public, bindable property.</summary>
 ///<param name="defaultValue">The default value to return if the property has never been set before.</param>
 protected T GetBindableProperty <T>(Expression <Func <T> > property, T defaultValue = default)
 {
     return((T)_dictionaryPrivateProperties.GetOrAdd(MemberUtils.GetMemberInfo(property).Name, defaultValue));
 }