Category / Section
How to localize DateTimeEdit Today Button Text?
1 min read
In DateTimeEdit control, it is possible to localize the Today Button content based on application requirement. It can be achieved by retrieving Today Button by customizing DateTimeEdit control Template.
The following Code sample demonstrates the same.
C#
// set the Button_Today_Classic template private void DateTimeEdit_Loaded(object sender, RoutedEventArgs e) { ToggleButton button = DateTimeEdit1.Template.FindName("Button_Today_Classic", DateTimeEdit1) as ToggleButton; if(button != null) { button.Content = "Klick mich"; } }
VB
' set the Button_Today_Classic template ‘ Private Sub DateTimeEdit_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) Dim button As ToggleButton = TryCast(DateTimeEdit1.Template.FindName("Button_Today_Classic", DateTimeEdit1), ToggleButton) If button IsNot Nothing Then button.Content = "Klick mich" End If End Sub
Screenshot
Figure 1: Before localization
Figure 2: After localization