System.Windows.FrameworkElement.SetBinding C# (CSharp) Method

SetBinding() public method

public SetBinding ( DependencyProperty dp, Binding binding ) : BindingExpressionBase
dp DependencyProperty
binding Binding
return BindingExpressionBase
		public BindingExpressionBase SetBinding (DependencyProperty dp, Binding binding)
		{
			return BindingOperations.SetBinding (this, dp, binding);
		}

Usage Example

Example #1
1
        public static void SetBindingObject(FrameworkElement obj, BindingMode mode, object source, DependencyProperty dp, string propertyName)
        {
            Type propertyType = source.GetType().GetProperty(propertyName).PropertyType;
            PropertyInfo info = source.GetType().GetProperty("RangeList");
            FANumberRangeRule rangeRule = null;
            if (info != null)
            {
                object value = info.GetValue(source, null);
                if (value != null)
                {
                    FALibrary.Utility.SerializableDictionary<string, FARange> dic =
                        (FALibrary.Utility.SerializableDictionary<string, FARange>)value;
                    if (dic.ContainsKey(propertyName))
                    {
                        rangeRule = new FANumberRangeRule(propertyType);
                        rangeRule.Range = dic[propertyName];
                        obj.Tag = rangeRule;
                        obj.Style = (Style)App.Current.Resources["TextBoxErrorStyle"];
                    }
                }
            }

            Binding bd = new Binding(propertyName);
            bd.Source = source;
            bd.Mode = mode;
            bd.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            if (rangeRule != null)
            {
                bd.NotifyOnValidationError = true;
                bd.ValidationRules.Add(rangeRule);
            }

            obj.SetBinding(dp, bd);
        }
All Usage Examples Of System.Windows.FrameworkElement::SetBinding