メイン ページのテキスト ボックスは、ポップアップであるユーザー コントロールの文字列プロパティにバインドされています。テキスト ボックスの値は文字列プロパティの初期値で正しく表示されますが、プロパティを変更しても表示される値は更新されません。このフィールドでプロパティの変更を監視するにはどうすればよいですか?
**MainPage XAML:**
<TextBox x:Name="textBlockStartDate" Text="{Binding selectedDateString,Mode=OneWay}" DataContext="{Binding ElementName=MyUserControl}"/>
**MyUserControl.cs**
private DateTime selectedDate;
public string selectedDateString {get{return selectedDate.Date.ToString("dd.MM.yyyy");}}
public DatePicker(){
this.InitializeComponent();
selectedDate = DateTime.Today;
}
// Update the value when a button is pressed
private void DayButton_Clicked(object sender, RoutedEventArgs e){
Button button = (Button)sender;
selectedDate = (DateTime)button.Tag;
}