WPF complex DataGridColumn - First Name + Last Name Sort, single cell display

676 Views Asked by At

Say I have the following class:

public class Name
{
    public string First {get;set;}
    public string Last {get;set;}
    public string FullName
    {
        get
        {
            return String.Format("{0} {1}", this.First, this.Last);
        }
    } 
}

How would I implement 2 DataGridColumns (1 for First Name, 1 for Last Name), so they can be "column-header click sorted", but so these 2 columns display as a single cell, showing the "FullName" property?

FYI - answers for .NET DataGrid or Extended WPF Toolkit DataGridControl welcome, as well as anything conceptual or helping to point me in the right direction.

1

There are 1 best solutions below

0
raghava arr On

You can use Multibinding in that specify string format in xaml.

Example

<MultiBinding StringFormat="{}{0}  {1}">
    <Binding Path="FirstName" />
    <Binding Path="LastName" />
</MultiBinding>

String format using MultiBinding?