I am new to UWP and would like to know if there is any way to pass information from one Date Picker to another new one, what I have in XAML is
<StackPanel Name = "ContenedorElementos">
<CalendarDatePicker Name="FechaEntr" Margin="0,0,30,0" PlaceholderText="Fecha entrega" />
<Button Content="Agregar" Width="100" Click="Button_Click"/>
</StackPanel>
In C # I have the following
private void Button_Click(object sender, RoutedEventArgs e)
{
StackPanel nuevoItem = new StackPanel();
nuevoItem.VerticalAlignment = VerticalAlignment.Center;
nuevoItem.VerticalAlignment = VerticalAlignment.Center;
nuevoItem.Margin = new Thickness(0,0,0,30);
nuevoItem.Orientation = Orientation.Horizontal;
nuevoItem.Children.Add(
new DatePicker
{
//Aquí quiero pasar la información de "FechaEntr" al nuevo DatePicker
);
ContenedorElementos.Children.Add(nuevoItem); //El StackPanel al que va entrar el nuevo StackPanel con el DatePicker
}
Is there any way to put the "DateEntr" information to the new DatePicker?
I edit, I solved occupying the code below, it seems that we should only store the values in an implicit variable and then send them to the constructor of a new DateTime.
var valoresFechEntr = FechaEntr.Date;
nuevoItem.Children.Add(
new DatePicker
{
Date = new DateTime(valoresFechEntr.Value.Day, valoresFechEntr.Value.Month, valoresFechEntr.Value.Year)
});