:
Add the following code to the App.cs:
protected Override voidOnstartup (StartupEventArgs e) {Base. Onstartup (e); Eventmanager.registerclasshandler (typeof(DatePicker), Datepicker.loadedevent,NewRoutedeventhandler (datepicker_loaded)); } Public StaticT getchildoftype<t> (DependencyObject depobj)whereT:dependencyobject {if(Depobj = =NULL)return NULL; for(inti =0; I < Visualtreehelper.getchildrencount (depobj); i++) { varChild =Visualtreehelper.getchild (Depobj, i); varresult = (Child asT)?? Getchildoftype<t>(child); if(Result! =NULL)returnresult; } return NULL; } voidDatepicker_loaded (Objectsender, RoutedEventArgs e) { varDP = Sender asDatePicker; if(DP = =NULL)return; varTB = getchildoftype<datepickertextbox>(DP); if(TB = =NULL)return; varWM = TB. Template.findname ("Part_watermark", TB) asContentControl; if(WM = =NULL)return; Wm. Content="Select a Date"; }
WPF DatePicker Watermark modified to Chinese