Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. advanced datagrid column binding (for a datetime)

advanced datagrid column binding (for a datetime)

Scheduled Pinned Locked Moved WCF and WF
databasewpfwcfooptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redivider
    wrote on last edited by
    #1

    I'm using an unconventional object oriented database which uses a long to store datetimes. This is directly convertible to a DateTime, but how could i display it as a DateTime using column binding? Because of the object oriented database i can't add an accessor to the class that returns the long casted to a DateTime (ex. DateTime.FromFileTime(timeStamp) ), becuase the db does not know how to correctly handle it. Is there something I could do with string.format? Or something i could do if i had a different column type (instead of Microsoft.Windows.Controls.DataGridTextColumn)? Seems far-fetched, but how about a column that can bind to a method's return value? I'm trying to avoid having to inherit from the type used in the DB but as a last resort I could do that.

    A 1 Reply Last reply
    0
    • R redivider

      I'm using an unconventional object oriented database which uses a long to store datetimes. This is directly convertible to a DateTime, but how could i display it as a DateTime using column binding? Because of the object oriented database i can't add an accessor to the class that returns the long casted to a DateTime (ex. DateTime.FromFileTime(timeStamp) ), becuase the db does not know how to correctly handle it. Is there something I could do with string.format? Or something i could do if i had a different column type (instead of Microsoft.Windows.Controls.DataGridTextColumn)? Seems far-fetched, but how about a column that can bind to a method's return value? I'm trying to avoid having to inherit from the type used in the DB but as a last resort I could do that.

      A Offline
      A Offline
      AspDotNetDev
      wrote on last edited by
      #2

      You can either use an IValueConverter or StringFormat in your binding. You could also wrap your object in another object that exposes a property that does custom string formatting, but that would be a lot of extra work you don't need if you use the above techniques I mentioned.

      [Forum Guidelines]

      R 1 Reply Last reply
      0
      • A AspDotNetDev

        You can either use an IValueConverter or StringFormat in your binding. You could also wrap your object in another object that exposes a property that does custom string formatting, but that would be a lot of extra work you don't need if you use the above techniques I mentioned.

        [Forum Guidelines]

        R Offline
        R Offline
        redivider
        wrote on last edited by
        #3

        Thanks. That IValueConverter is fun and I'll use it, but i was wondering what the code would look like to use stringformat. I can't quite figure it out.

        A 1 Reply Last reply
        0
        • R redivider

          Thanks. That IValueConverter is fun and I'll use it, but i was wondering what the code would look like to use stringformat. I can't quite figure it out.

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #4

          Hmmm, you'd probably have to do some math to get it to display in the proper format... not sure you can do that with StringFormat, now that I think about it. I'd stick with IValueConverter.

          [Forum Guidelines]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups