Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    DependencyPropertyBehavior Class

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

    Namespace: DevExpress.Mvvm.UI

    Assembly: DevExpress.Xpf.Core.v25.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

    #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