UWP C # Pass date picker to another

1

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) 
});
    
asked by Amaury Permer 18.12.2016 в 22:36
source

1 answer

1

What happens if you simply use

var valoresFechEntr = FechaEntr.Date.Value; 

nuevoItem.Children.Add(new DatePicker { Date = valoresFechEntr });

in this case you assign the DateTime directly from the date of delivery to the date the picker that you create by code

    
answered by 20.12.2016 / 05:28
source