0

In a WPF MVVM (caliburn micro) application I need to bind a DateTimeOffset property to a wpf DatePicker control (SelectedDate property).

I think I can use caliburn micro's value converter feature to convert DateTimeOffset to DateTime and vice versa. Could anyone please provide me the steps with sample code?

<DatePicker SelectedDate="{Binding DateOfBirth}"/>
Rahul
  • 2,431
  • 3
  • 35
  • 77
  • 1
    IValueConverter isn't a CM thing its a .net Framework feature. Here is a definition and an example https://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter(v=vs.110).aspx http://blogs.msdn.com/b/bencon/archive/2006/05/10/594886.aspx – mvermef Oct 11 '15 at 16:52
  • Yes i know that the IValueConverter isn't a CM thing. But according to the CM documentation there is an easy way to implement IValueConverter in CM. I know how to implement it, but i'm struggling to apply it in view. For a example i need to apply iValueConverter to convert DateTimeOffset to DateTime. How can i do this? `` – Rahul Oct 12 '15 at 06:06
  • Thanks, it's working! – Rahul Oct 13 '15 at 03:51
  • Late to the party, but I think this is what's referred to in the docs: https://stackoverflow.com/questions/19175245/how-do-you-apply-a-valueconverter-to-a-convention-based-caliburn-micro-binding-e/19178116#19178116 – mottosson Nov 08 '19 at 16:04

1 Answers1

1

<DatePicker SelectedDate="{Binding DateofBirth, Converter={StaticResource DateConverter}}" /> which means you would need to write a converter from datetime to DateTimeOffSet. Not really all that hard. It has nothing to do with Caliburn Micro, not sure what docs you are referring to..

mvermef
  • 3,814
  • 1
  • 23
  • 36