Category / Section
How to set Different pattern in DatetimeEdit Control?
1 min read
To set the different pattern for the dates in the DateTimeEdit control, the Pattern property can be used. The Pattern property consist of different values, as follows below:
- Custom pattern
- Short Date
- FullDateTime
- LongDate
- LongTime
- MonthDay
- RFC1123
- ShortDate
- ShortTime
- SortableDateTime
- UniversableSortableDateTime
- YearMonth
The following code snippet shows how to set the YearMonth pattern in the DateTimeEdit control using Pattern property. Similarly, the different patterns can be set using the Pattern property.
XAML:
<Window x:Class="DockingManager_KB.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:syncfusion="http://schemas.syncfusion.com/wpf" Title="MainWindow" Height="350" Width="525"> <Grid x:Name="Grid1"> <syncfusion:DateTimeEdit x:Name="_DateTimeEdit" Width="250" Height="23" Pattern="YearMonth" /> </Grid> </Window>
C#:
using Syncfusion.Windows.Shared; namespace DockingManager_KB { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DateTimeEdit datetimeedit = new DateTimeEdit(); datetimeedit.Width = 250; datetimeedit.Height = 23; datetimeedit.Pattern = DateTimePattern.YearMonth; Grid1.Children.Add(datetimeedit); } } }
Output:
The following output shows the Year and Month by setting YearMonth pattern