Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
250
How to bind two columns to the same field in the data source?
posted

I have data in my XamDataGrid where each element has two properties.

class Thing

{

  public DateTime Occasion { get; set; } 

  public string Information { get; set; }

}

I'd like to show three columns, though. One for each of the properties and an additional one for the date but only showing the year. At the moment I do that by introducing an auxiliary class as follows.

class ThingUi

{

  public DateTime Occasion { get; set; }

  public String Year { get{ return Occasion.ToString("yyyy"); } }

  public string Information { get; set; }

}

I'd prefer to bind a two columns to the same field and simply format or convert it to my needs. At the moment, the stupid computer says that such an object doesn't exists in the collection provided (from my view model), as if the field has been "used up" at the first binding attempt. NB. I only need to display the date. Any manipulation and storing back to the database's done elsewhere.

Parents Reply Children
No Data