private void UserControl_Loaded(object sender, RoutedEventArgs e) { Persona p = new Persona() { Nome = "Antonio", Cognome = "Pelleriti", DataNascita = new DateTime(1975, 4, 18) }; LayoutRoot.DataContext = p; Binding binding = new Binding(); binding.Path =new PropertyPath("Nome"); binding.Mode = BindingMode.TwoWay; txtNome.SetBinding(TextBox.TextProperty, binding); binding = new Binding(); binding.Path = new PropertyPath("Cognome"); binding.Mode = BindingMode.TwoWay; txtCognome.SetBinding(TextBox.TextProperty, binding); binding = new Binding(); binding.Path = new PropertyPath("DataNascita"); binding.Mode = BindingMode.TwoWay; dp.SetBinding(DatePicker.SelectedDateProperty, binding); binding = new Binding(); binding.Path = new PropertyPath("Eta"); binding.Mode = BindingMode.TwoWay; txtEta.SetBinding(TextBlock.TextProperty, binding); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { Persona p = new Persona() { Nome = "Antonio", Cognome = "Pelleriti", DataNascita = new DateTime(1975, 4, 18) }; LayoutRoot.DataContext = p; }
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { m_persona = new Persona(); //m_persona.DataNascita = DateTime.Today.AddYears(-50); LayoutRoot.DataContext = m_persona; }