wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-a2715068.md
Gets or sets a command that customizes a data cell‘s display text.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public ICommand<NodeDisplayTextArgs> CustomColumnDisplayTextCommand { get; set; }
Public Property CustomColumnDisplayTextCommand As ICommand(Of NodeDisplayTextArgs)
| Type | Description |
|---|---|
| ICommand<NodeDisplayTextArgs> |
Contains properties that identify the processed cell.
|
Bind a command to the CustomColumnDisplayTextCommand property to maintain a clean MVVM pattern. The command works like a CustomColumnDisplayText event handler and allows you to customize a data cell’s display text in a View Model.
The command is called for bound and unbound columns. The printed GridControl also displays customized text.
The DisplayTextArgs.DisplayText property contains a cell’s display text. To customize the display text, assign a string value to this property.
<dxg:GridControl ItemsSource="{Binding Source}">
<dxg:GridControl.View>
<dxg:TreeListView CustomColumnDisplayTextCommand="{Binding CustomColumnDisplayTextCommand}"/>
</dxg:GridControl.View>
<dxg:TreeListColumn FieldName="ProductName" IsSmart="True"/>
<dxg:TreeListColumn FieldName="Country" IsSmart="True"/>
<dxg:TreeListColumn FieldName="City" IsSmart="True"/>
<dxg:TreeListColumn FieldName="Value" IsSmart="True"/>
</dxg:GridControl>
using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Mvvm.Xpf;
public class ViewModel : ViewModelBase {
// ...
[Command]
public void CustomColumnDisplayText(NodeDisplayTextArgs e) {
if (e.FieldName == "Value")
e.DisplayText = string.Format("{0:n2}", e.Value);
}
}
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.DataAnnotations
Imports DevExpress.Mvvm.Xpf
Public Class ViewModel
Inherits ViewModelBase
<Command>
Public Sub CustomColumnDisplayText(ByVal e As NodeDisplayTextArgs)
If e.FieldName = "Value"
Then e.DisplayText = String.Format("{0:n2}", e.Value)
End Sub
End Class
See Also