mardi 31 mars 2015

Present string different in View than what it's set in ViewModel

I'm working on a project on Windows Phone 8 w/ SQLite, and I've been working with dates and times, and recently I've had to start using some aggregate functions to select some data, but these can only be implemented if the datetime strings are formatted in a certain way (SQLite DateTime) so I've had to change the formatting of these values so I get the results I expect from the aggregate queries.


My problem is that these formats aren't really the most appealing when presenting the data to the user. For example, before using aggregate functions, I was displaying a duration as "23h 32m 21s" (h'h 'm'm 's's') or a date as Tuesday 31 March 2015 (dddd dd MMMM yyyy) but I had to change these to the formats SQLite uses to perform aggregate queries, so they now read 00:00:00 for duration and 2015-03-31 for dates, etc.


Is there any way where you can change the format when presenting the data to the user regardless of how it's formatted and inserted into the database in the ViewModel/C#? I've tried using a StringFormatConverter and setting the parameter to my preferred format, but that didn't work.


Thanks.


Aucun commentaire:

Enregistrer un commentaire