本文整理汇总了C#中System.Windows.Data.BindingBase类的典型用法代码示例。如果您正苦于以下问题:C# BindingBase类的具体用法?C# BindingBase怎么用?C# BindingBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BindingBase类属于System.Windows.Data命名空间,在下文中一共展示了BindingBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDisplayMemberBinding
internal void SetDisplayMemberBinding( BindingBase value )
{
// Disable warning for DisplayMemberBinding when internaly used
#pragma warning disable 618
this.DisplayMemberBinding = value;
#pragma warning restore 618
}
示例2: ConditionItem
/// <summary>
/// Initializes a new instance of the <see cref="ConditionItem"/> class.
/// </summary>
public ConditionItem(BindingBase binding, object instance, object value)
{
_binding = binding;
_instance = instance;
_value = value;
HookBinding();
}
示例3: Create
internal static Column Create( string fieldName, object title, BindingBase displayMemberBinding )
{
// Disable warning for DisplayMemberBinding when internaly used
#pragma warning disable 618
var column = new Column( fieldName, title, displayMemberBinding );
#pragma warning restore 618
return column;
}
示例4: Column
public Column( string fieldName, object title, BindingBase displayMemberBinding )
: base( fieldName, title )
{
// Disable warning for DisplayMemberBinding when internaly used
#pragma warning disable 618
this.DisplayMemberBinding = displayMemberBinding;
#pragma warning restore 618
}
示例5: ClearBindingDisposable
public ClearBindingDisposable(DependencyObject target, DependencyProperty property, BindingBase binding)
{
Contract.Requires(target != null);
Contract.Requires(property != null);
Contract.Requires(binding != null);
m_Target = target;
m_Property = property;
m_Binding = binding;
}
示例6: Condition
/// <summary>
/// Constructor for creating a Condition with the given binding declaration.
/// and value.
/// </summary>
public Condition( BindingBase binding, object conditionValue )
{
if( binding == null )
{
throw new ArgumentNullException("binding");
}
Binding = binding;
Value = conditionValue;
}
示例7: Dispose
public void Dispose()
{
if (m_Target == null) throw new ObjectDisposedException("ClearBindingDisposable");
if (object.ReferenceEquals(BindingOperations.GetBindingBase(m_Target, m_Property), m_Binding))
{
BindingOperations.ClearBinding(m_Target, m_Property);
}
m_Target = null;
m_Property = null;
m_Binding = null;
}
示例8: ApplyBinding
private static void ApplyBinding(BindingBase binding, DependencyObject target, DependencyProperty property)
{
if (binding != null)
{
BindingOperations.SetBinding(target, property, binding);
}
else
{
BindingOperations.ClearBinding(target, property);
}
}
示例9: GetBindingValue
/// <summary>
/// Gets the binding value.
/// </summary>
/// <param name="frameworkElement">The dependency object.</param>
/// <param name="binding">The binding.</param>
/// <returns>The actual binding value.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="frameworkElement"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentNullException">The <paramref name="binding"/> is <c>null</c>.</exception>
public static object GetBindingValue(FrameworkElement frameworkElement, BindingBase binding)
{
Argument.IsNotNull("frameworkElement", frameworkElement);
Argument.IsNotNull("binding", binding);
var evaluator = new BindingEvaluator(frameworkElement.DataContext);
BindingOperations.SetBinding(evaluator, BindingEvaluator.ValueProperty, binding);
object value = evaluator.Value;
ClearBinding(evaluator, BindingEvaluator.ValueProperty);
return value;
}
示例10: EvaluateBinding
/// <summary>
/// Evaluates a WPF data binding.
/// </summary>
/// <param name="dataContext">The data context.</param>
/// <param name="binding">The binding to evaluate.</param>
/// <returns></returns>
public static object EvaluateBinding(BindingBase binding, object dataContext)
{
var result = default(object);
if (dataContext != null)
{
var target = new TemporaryBindingTarget();
var duplicatedBinding = CloneBinding(binding, dataContext);
var expression = BindingOperations.SetBinding(target, TemporaryBindingTarget.ResultProperty,
duplicatedBinding);
expression.UpdateTarget();
result = target.Result;
BindingOperations.ClearBinding(target, TemporaryBindingTarget.ResultProperty);
}
return result;
}
示例11: SetBinding
//-----------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
/// <summary>
/// Attach a BindingExpression to a property.
/// </summary>
/// <remarks>
/// A new BindingExpression is created from the given description, and attached to
/// the given property of the given object. This method is the way to
/// attach a Binding to an arbitrary DependencyObject that may not expose
/// its own SetBinding method.
/// </remarks>
/// <param name="target">object on which to attach the Binding</param>
/// <param name="dp">property to which to attach the Binding</param>
/// <param name="binding">description of the Binding</param>
/// <exception cref="ArgumentNullException"> target and dp and binding cannot be null </exception>
public static BindingExpressionBase SetBinding(DependencyObject target, DependencyProperty dp, BindingBase binding)
{
if (target == null)
throw new ArgumentNullException("target");
if (dp == null)
throw new ArgumentNullException("dp");
if (binding == null)
throw new ArgumentNullException("binding");
// target.VerifyAccess();
BindingExpressionBase bindExpr = binding.CreateBindingExpression(target, dp);
//
target.SetValue(dp, bindExpr);
return bindExpr;
}
示例12: SetBinding
public static BindingExpressionBase SetBinding (DependencyObject target, DependencyProperty dp, BindingBase binding)
{
if (target == null)
throw new ArgumentNullException ("target");
if (dp == null)
throw new ArgumentNullException ("dp");
if (binding == null)
throw new ArgumentNullException ("binding");
if (dp == null)
throw new ArgumentNullException ("dp");
if (binding == null)
throw new ArgumentNullException ("binding");
BindingExpression e = new BindingExpression ((Binding) binding, target, dp);
target.SetValue (dp, e);
return e;
}
示例13: CloneBinding
public static Binding CloneBinding(BindingBase bindingBase, object source)
{
var binding = bindingBase as Binding;
if (binding != null)
{
var result = new Binding
{
Source = source,
AsyncState = binding.AsyncState,
BindingGroupName = binding.BindingGroupName,
BindsDirectlyToSource = binding.BindsDirectlyToSource,
Converter = binding.Converter,
ConverterCulture = binding.ConverterCulture,
ConverterParameter = binding.ConverterCulture,
//ElementName = binding.ElementName,
FallbackValue = binding.FallbackValue,
IsAsync = binding.IsAsync,
Mode = binding.Mode,
NotifyOnSourceUpdated = binding.NotifyOnSourceUpdated,
NotifyOnTargetUpdated = binding.NotifyOnTargetUpdated,
NotifyOnValidationError = binding.NotifyOnValidationError,
Path = binding.Path,
//RelativeSource = binding.RelativeSource,
StringFormat = binding.StringFormat,
TargetNullValue = binding.TargetNullValue,
UpdateSourceExceptionFilter = binding.UpdateSourceExceptionFilter,
UpdateSourceTrigger = binding.UpdateSourceTrigger,
ValidatesOnDataErrors = binding.ValidatesOnDataErrors,
ValidatesOnExceptions = binding.ValidatesOnExceptions,
XPath = binding.XPath,
};
foreach (var validationRule in binding.ValidationRules)
{
result.ValidationRules.Add(validationRule);
}
return result;
}
return null;
}
示例14: CloneBinding
/// <summary>
/// Clones a binding and assigns a different data context.
/// </summary>
/// <param name="original">The original.</param>
/// <param name="replacementDataContext">The replacement data context.</param>
/// <returns></returns>
private static BindingBase CloneBinding(BindingBase original, object replacementDataContext)
{
if (original is Binding)
{
var originalBinding = (Binding) original;
var duplicate = new Binding();
duplicate.BindsDirectlyToSource = originalBinding.BindsDirectlyToSource;
duplicate.Converter = originalBinding.Converter;
duplicate.ConverterCulture = originalBinding.ConverterCulture;
duplicate.ConverterParameter = originalBinding.ConverterParameter;
duplicate.FallbackValue = originalBinding.FallbackValue;
duplicate.IsAsync = originalBinding.IsAsync;
duplicate.Mode = originalBinding.Mode;
duplicate.Path = originalBinding.Path;
// Decide on a source
if (originalBinding.RelativeSource != null) duplicate.RelativeSource = originalBinding.RelativeSource;
else if (originalBinding.ElementName != null) duplicate.ElementName = originalBinding.ElementName;
else duplicate.Source = replacementDataContext;
return duplicate;
}
throw new NotSupportedException();
}
示例15: GenerateDefaultDisplayTemplate
/// <summary>
/// BooleanTreeColumn 用于显示的元素也直接是一个 CheckBox
/// </summary>
/// <param name="binding"></param>
/// <returns></returns>
protected override FrameworkElementFactory GenerateDefaultDisplayTemplate(BindingBase binding)
{
var cb = new FrameworkElementFactory(typeof(CheckBox));
cb.SetBinding(CheckBox.IsCheckedProperty, binding);
var style = this.DisplayCheckBoxStyle;
if (style != null) cb.SetValue(CheckBox.StyleProperty, style);
//把 TreeGrid.IsReadOnly 属性反向绑定到 IsEanbled 属性上。
//这是由于这个列直接使用显示的控件作为编辑的控件,所以这个显示控件的只读性,需要与 TreeGrid 的只读性保持同步。
cb.SetBinding(CheckBox.IsEnabledProperty, new Binding
{
Path = new PropertyPath(TreeGrid.IsReadOnlyProperty),
Converter = new ReverseBooleanConverter(),
RelativeSource = new RelativeSource
{
Mode = RelativeSourceMode.FindAncestor,
AncestorType = typeof(TreeGrid)
}
});
return cb;
}