binding - WPF bound DatePicker not updating source -


in view.xaml have datepicker bound viewmodel's date property

<datepicker selecteddate="{binding path=date, mode=twoway, converter={staticresource ifnulldateconverter}}" /> 

when view.xaml shown "ifnullconverter" used convert default datetime value "01.01.0001" datetime.now, datepicker displays current date. selecteddate property not set. why?

when press save button, datepicker value passed viewmodel still "01.01.0001".

please help, doing wrong? how update source code pass current date if date "01.01.0001"?

ifnulldateconverter

datetime datevalue = (datetime)value;             if (datevalue.toshortdatestring() == "01.01.0001")             {                 return datetime.now;             }             else             {                 return value;              } 

this right behavior. should use converter when want convert source value( date in vm) , set desdination(selecteddate) new value. means when convert source value, result doesnt affect it, destination. conclusion : if want set default value datetime.now property, should in vm


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -