c# - WPF Calendar selecteddate not binding + single click to select date? -


short info: i'm trying develop program administration of daycare center, of "visitors" come here every day, want come 1 day or want stay home. wanted use calendar user can select date's visitor come.

i'm using wpf , mvvmc patern.

problem 1, have date visitor in database, when try bind selecteddate doesn't work. if read date in textbox see date correctly.

problem 2, can not use selecteddates of calendarcontrol there work around? user needs ability select , view more 1 date.

problem 3, there way can modify calendar each date function checkbox, if want select more dates need hold ctrl , want single click select keep program easy work with.

thanks lot, btw i'm beginning programmer, don't have lot of experience, have nice idea , want work out properly, please go easy on me.

you should set both displaydate="{binding registerdate}" , selecteddate="{binding registerdate}".

try :

xaml code :

<calendar x:name="mycalender" displaydate="{binding registerdate}" selecteddate="{binding registerdate}" /> <textbox x:name="txtvisitorid" /> <button name="btnbinddate" click="btnbinddate_onclick" content="setcurrentdate"/> 

cs code :

private void binddata(int visitorid) {     using (var context = samplecontext.getcontext())     {         var visitor = context.visitors.firstordefault(x => x.visitorid == visitorid);         mycalender.datacontext = visitor;     } }  private void btnbinddate_onclick(object sender, routedeventargs e) {     var id = int.parse(txtvisitorid.text);     binddata(id); } 

visitor class :

public class visitor {     [key]     public int visitorid { get; set; }     public string name { get; set; }     public datetime registerdate { get; set; } } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -