Skip to main content
A newer version of this page is available. .
All docs
V21.1

DependencyPropertyBehavior Class

Allows you to bind a ViewModel property to a control’s non-dependency property.

Namespace: DevExpress.Mvvm.UI

Assembly: DevExpress.Xpf.Core.v21.1.dll

NuGet Package: DevExpress.Wpf.Core

Declaration

public class DependencyPropertyBehavior :
    Behavior<DependencyObject>

Remarks

To bind a ViewModel property to a control’s non-dependency property, specify the following DependencyPropertyBehavior properties:

Property Description
Binding Gets or sets the binding that should be applied to the specified property. This is a dependency property.
EventName Gets or sets the name of the event the DependencyPropertyBehavior handles to update the binding.
PropertyName Gets or sets a control’s property name (the binding’s target).

The following code sample binds the ViewModel’s SelectedTextBoxText property to the TextBox.SelectedText non-dependency property:

<UserControl x:Class="Example.View.MainView"
<!-- ... -->
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    <!-- ... -->
        <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
            <!--The TextBox.SelectedText property is not a dependency property-->
            <TextBox Width="200" Text="Select some text in this box">
                <dxmvvm:Interaction.Behaviors>
                    <dxmvvm:DependencyPropertyBehavior PropertyName="SelectedText" EventName="SelectionChanged" Binding="{Binding SelectedTextBoxText, Mode=TwoWay}"/>
                </dxmvvm:Interaction.Behaviors>
            </TextBox>
            <TextBox Width="200" Text="{Binding SelectedTextBoxText}" IsReadOnly="True"/>
        </StackPanel>
        <!-- ... -->
</UserControl>
using DevExpress.Mvvm;

namespace Example.ViewModel {
    public class MainViewModel : ViewModelBase {
        public virtual string SelectedTextBoxText { get; set; }
    }
}

Run Demo: Behaviors Module in the WPF MVVM Demo

View Example: WPF MVVM Framework - Bind a ViewModel's Property to a Control's Non Dependency Property

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DependencyPropertyBehavior class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

Object
DispatcherObject
DependencyObject
Freezable
Animatable
DevExpress.Mvvm.UI.Interactivity.AttachableObjectBase
DevExpress.Mvvm.UI.Interactivity.Behavior
DevExpress.Mvvm.UI.Interactivity.Behavior<DependencyObject>
DependencyPropertyBehavior
See Also