Search code examples
xamldevexpressgridcontrol

How to provide if and else Formatter in Devxpress Gridcontrol using Xaml?


I am developing an app using Devexpress Gridcontrol using Xaml. In a cell Template i am having a Textblock in which i want to Display 'Open' if the value in Binding is '0' and 'Close' if it is '0'. Can this be done using FormatterString ie. Using FormatStringConverter?


Solution

  • Hope this helps. :)

    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
    
    
    <TextBlock Text="{Binding Value}">
      <i:Interaction.Triggers>
        <ei:DataTrigger Value="0" Binding="{Binding Text, ElementName=Self}">
            <im:ChangePropertyAction PropertyName="Text"
                                             Value="Open"/>
        </ei:DataTrigger>
        <ei:DataTrigger Value="1" Binding="{Binding Text, ElementName=Self}">
            <im:ChangePropertyAction PropertyName="Text"
                                             Value="Close"/>
        </ei:DataTrigger>
      </i:Interaction.Triggers>
    </TextBlock>