public : sealed class BindingOperations : IBindingOperations
struct winrt::Windows::UI::Xaml::Data::BindingOperations : IBindingOperations
public sealed class BindingOperations : IBindingOperations
Public NotInheritable Class BindingOperations Implements IBindingOperations
Windows 10 (introduced v10.0.10240.0)
Windows.Foundation.UniversalApiContract (introduced v1)
SetBinding(DependencyObject, DependencyProperty, BindingBase) SetBinding(DependencyObject, DependencyProperty, BindingBase) SetBinding(DependencyObject, DependencyProperty, BindingBase) SetBinding(DependencyObject, DependencyProperty, BindingBase)
public : static void SetBinding(DependencyObject target, DependencyProperty dp, BindingBase binding)
void SetBinding(DependencyObject target, DependencyProperty dp, BindingBase binding) const;
public static void SetBinding(DependencyObject target, DependencyProperty dp, BindingBase binding)
Public Static Function SetBinding(target As DependencyObject, dp As DependencyProperty, binding As BindingBase) As void
The object that should be the target of the evaluated binding.
The property on the target to bind, specified by its identifier. These identifiers are usually available as static read-only properties on the type that defines the target object, or one of its base types. You can also bind to attached properties, but see Remarks.
You can bind to custom dependency properties or custom attached properties, the identifier you pass as the dp parameter doesn't have to be a Windows Runtime defined property.
BindingOperations.SetBinding is a static utility method, and does basically the same thing as FrameworkElement.SetBinding. It's more common to use FrameworkElement.SetBinding because it's an instance method. One important difference though is that BindingOperations.SetBinding can use a target value of any DependencyObject, whereas FrameworkElement.SetBinding can by definition only be used for a FrameworkElement target. This doesn't usually matter for most Windows Runtime classes used for XAML UI, because these are mostly FrameworkElement subclasses anyways. But the distinction might matter if you are targeting bindings on your own custom classes that derive from DependencyObject or UIElement.
Calling the SetBinding method and passing in a new Binding object won't necessarily remove an existing binding. Instead, you should first call the DependencyObject.ClearValue method, then call SetBinding.
Binding to attached properties
You can put data bindings on any attached properties that a target object supports. Technically an DependencyObject supports all the possible attached properties, but you'd usually only set a binding on an attached property that's relevant to that object or your scenario. For example you would set a binding on Grid.Row only if you anticipate that the target element has a Grid parent that will use that info. Specify the dp parameter as the dependency property identifier that exists on the attached property's owner class (for the Grid.Row example, that identifier is Grid.RowProperty ). You won't find that identifier on the target because it's an attached property. For more info on attached properties, see Attached properties overview.
- See Also