Skip to main content

Example

  • 5 minutes to read

This example demonstrates cases of the DXBinding, DXCommand, and DXEvent markup extensions.

View Example: Use DXBinding, DXCommand, and DXEvent Extensions

<UserControl x:Class="DXBindingExample.View.BasicExpressionsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:v="clr-namespace:DXBindingExample.View"
             xmlns:vm="clr-namespace:DXBindingExample.ViewModel"
             xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
             mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="800"
             d:DataContext="{dxmvvm:ViewModelSource vm:BasicExpressionsViewModel}">

    <StackPanel Orientation="Vertical">
        <StackPanel Style="{StaticResource groupPanelStyle}">
            <TextBlock Text="ViewModel Properties" Style="{StaticResource headerDescriptionStyle}"/>
            <TextBlock Text="IntValue:" Style="{StaticResource descriptionStyle}"/>
            <TextBox Text="{DXBinding 'IntValue', UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource valueStyle}"/>
            <TextBlock Text="DoubleValue:" Style="{StaticResource descriptionStyle}"/>
            <TextBox Text="{DXBinding 'DoubleValue', UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource valueStyle}"/>
            <TextBlock Text="StringValue:" Style="{StaticResource descriptionStyle}"/>
            <TextBox Text="{DXBinding 'StringValue', UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource valueStyle}"/>
            <TextBlock Text="BooleanValue:" Style="{StaticResource descriptionStyle}"/>
            <CheckBox IsChecked="{DXBinding 'BooleanValue', UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource valueStyle}"/>
        </StackPanel>
        <StackPanel Style="{StaticResource groupPanelStyle}">
            <TextBlock Text="Arithmetic Operators" Style="{StaticResource headerDescriptionStyle}"/>
            <TextBlock Text="DXBinding Expr: 'IntValue+DoubleValue'." Style="{StaticResource descriptionStyle}"/>
            <TextBox Text="{DXBinding 'IntValue+DoubleValue', Mode=OneWay}" IsReadOnly="True" Style="{StaticResource valueStyle}"/>
            <TextBlock Text="DXBinding Expr: 'StringValue+DoubleValue.ToString()'." Style="{StaticResource descriptionStyle}"/>
            <TextBox Text="{DXBinding 'StringValue+DoubleValue.ToString()', Mode=OneWay}" IsReadOnly="True" Style="{StaticResource valueStyle}"/>
        </StackPanel>
        <StackPanel Style="{StaticResource groupPanelStyle}">
            <TextBlock Text="Comparison and Relational Operators " Style="{StaticResource headerDescriptionStyle}"/>
            <TextBlock Text="DXBinding Expr: 'IntValue eq(==) DoubleValue'." Style="{StaticResource descriptionStyle}"/>
            <TextBox Text="{DXBinding 'IntValue eq DoubleValue', Mode=OneWay}" IsReadOnly="True" Style="{StaticResource valueStyle}"/>
            <TextBlock Text="DXBinding Expr: 'IntValue gt(>) DoubleValue'." Style="{StaticResource descriptionStyle}"/>
            <TextBox Text="{DXBinding 'IntValue gt DoubleValue', Mode=OneWay}" IsReadOnly="True" Style="{StaticResource valueStyle}"/>
        </StackPanel>
        <StackPanel Style="{StaticResource groupPanelStyle}">
            <TextBlock Text="Logical Operators " Style="{StaticResource headerDescriptionStyle}"/>
            <TextBlock Text="DXBinding Expr: 'BooleanValue ? IntValue : DoubleValue'." Style="{StaticResource descriptionStyle}"/>
            <TextBox Text="{DXBinding 'BooleanValue ? IntValue : DoubleValue', Mode=OneWay}" IsReadOnly="True" Style="{StaticResource valueStyle}"/>
        </StackPanel>
    </StackPanel>
</UserControl>