views:

87

answers:

1

How could I reach the string value of DatePicker which located in another WPF window?

Something like that (on button click):

private void button1_Click(object sender, RoutedEventArgs e)
    {
        datePicker1.Text = datePickerFromAnotherWindow.Text;//error: the name does not exist in the current context
    }

DatePicker is from default WPF toolset

A: 

You should use a view model with a date/time property (either using dependency properties or INotifyPropertyChanged) on it so that when it is updated in one dt picker, its updated in the other. This way, the data is independent of the view (your "window")

Muad'Dib