c# - Selecteddate not updated in wpf datepicker when datepicker contains plain wpf textbox -
i have extended wpf date picker control , in styles changed template date picker textbox style. put textbox in control template of datepickertextbox:
<style x:key="datepickertextboxstyle" targettype="{x:type datepickertextbox}"> <setter property="height" value="20" /> <setter property="control.template"> <setter.value> <controltemplate> <textbox x:name="part_textbox" style="{dynamicresource calendartextboxstyle}" tabindex="0" text="{binding path=selecteddate, stringformat='d', converterculture={x:static glob:cultureinfo.currentculture}, relativesource={relativesource ancestortype={x:type maskeddatepickerlib:maskeddatepicker}}}" textwrapping="wrap"> </textbox> </controltemplate> </setter.value> </setter> </style>
i have overridden default template date picker control style datepicker textbox changed.
now, problem when select date through calender got displayed in text box through binding. when delete date through backspace , if try select same date again calender, not displayed in text box. when investigated through snoop saw in selecteddate property of datepicker control value deleted still there in text box text propery value empty deleted it. kindly suggest.
if @ default controltemplate
datepicker
control, see has 4 inner controls have names start part_
prefix. (you can find default controltemplate
datepicker
control in datepicker syles , templates page on msdn). here example linked page:
<button x:name="part_button" grid.column="1" foreground="{templatebinding foreground}" focusable="false" horizontalalignment="left" margin="3,0,3,0" grid.row="0" style="{staticresource dropdownbuttonstyle}" verticalalignment="top" />
the controls have names start part_
prefix internally used datepicker
class , not having them in new controltemplate
cause problems. class asks controls name , if not found, default functionality cannot completed.
furthermore, trying replace datepickertextbox
of built in functionality normal textbox
, wondering why default functionality not working properly... it's because removed , didn't replace it.
while can see have tried use part_
name clear don't fully understand does. part_textbox
control in default controltemplate
of type datepickertextbox
, yours of type textbox
, whatever datepicker
class control, cannot because of wrong type.
Comments
Post a Comment