You could try to refer to the following code.
Xaml:
<DatePicker x:Name="DtpCurrencyExchangeDate0" HorizontalAlignment="Left" VerticalAlignment="Top"
Text="{Binding Path=SelectedDate, ElementName=DtpCurrencyExchangeDate0, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ConverterCulture={x:Static gl:CultureInfo.CurrentCulture} }"
FirstDayOfWeek="Monday" SelectedDate="{Binding CurrencyExchangeDate, Mode=TwoWay}"
IsTodayHighlighted="True" Height="25"/>
<DatePicker x:Name="DtpCurrencyExchangePrevDate0" HorizontalAlignment="Left" VerticalAlignment="Top"
Text="{Binding Path= SelectedDate, ElementName=DtpCurrencyExchangePrevDate0, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,ConverterCulture={x:Static gl:CultureInfo.CurrentCulture}}"
FirstDayOfWeek="Monday" SelectedDate="{Binding CurrencyExchangePrevDate,Mode=TwoWay}"
IsTodayHighlighted="True" Height="25"/>
Codebehind:
using System;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Markup;
namespace DataPickerInput
{
public partial class MainWindow : Window,INotifyPropertyChanged
{
public MainWindow()
{
InitializeComponent();
DataContext = this;
this.Language = XmlLanguage.GetLanguage(
CultureInfo.CurrentCulture.IetfLanguageTag);
}
private DateTime currencyExchangePrevDate = DateTime.Now ;
public DateTime CurrencyExchangePrevDate
{
get { return currencyExchangePrevDate; }
set
{
currencyExchangePrevDate = value;
OnPropertyChanged("CurrencyExchangePrevDate");
}
}
private DateTime currencyExchangeDate = DateTime.Now;
public DateTime CurrencyExchangeDate
{
get { return currencyExchangeDate; }
set
{
currencyExchangeDate = value;
OnPropertyChanged("CurrencyExchangeDate");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(String propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
The result:
----------------------------------------------------------------------------
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.