locked
Cositas RRS feed

  • Question

  • //xaml
    <toolkit:DatePicker x:Name="dtpPf"
                                        Header="Fecha de compra" ValueChanged="dtpPf_ValueChanged" />
    
    
    using System.Windows.Media.Imaging;
    
    public MainPage()
    {
                dtpPf.Value = DateTime.Today;
                dtpPf_ValueChanged(null, null);
    }
    
    
    
    txbSalida.Text = "";
                int precio = 0;
                try 
    	            {
    
                        precio = int.Parse(txtPrecio.Text);
    		            if(precio<0)
                        {
                            throw new Exception("precio positivo");
                        }
    	            }
    //catch...
    
    
    if (dtpPf.Value == null) return;
    
    if(dtpFin.Value < dtpIncio.Value)
    {
    DateTime? tmp = dtpFin.Value;
    dtpFin.Value = dtpInicio.Value;
    dtpInicio.Value = tmp.Value;
    }
                TimeSpan dif = DateTime.Today - dtpPf.Value.Value;
                int dias = int.Parse(dif.Days.ToString());
                txbSalida1.Text = "\nDIAS: "+dias;
    //txbSalida1.Text = dias.Days.ToString("#,##0")+"dias";
    
    
    //IMPORTANT FOR BITMAPS: 
    //using System.Windows.Media.Imaging;
    
    <DataTemplate x:Key="ItemTemplateLista">
                <StackPanel Orientation="Horizontal">
                    <Image Source="{Binding Ico}"
                           Width="30"
                           Stretch="UniformToFill"/>
                    <TextBlock Text="{Binding Nombre}" Margin="12,0"/>
                    <TextBlock Text="{Binding Precio,ConverterCulture=es-ES,StringFormat='{}{0:C}'}"/>
                </StackPanel>
            </DataTemplate>
    
    <toolkit:ListPicker x:Name="cmbLista"
    ItemTemplate="{StaticResource ItemTemplateLista}"
    Header="LISTA" SelectionChanged="cmbLista_SelectionChanged" />
    
    
    //clase
    public class CTienda
        {
            public ImageSource Ico { get;  set; }
            public String Nombre { get; set; }
            public double Precio { get; set; }
        }
    //xaml.cs
    
    public MainPage()
            {
                InitializeComponent();
                List<CTienda> tienda = new List<CTienda>();
    
     tienda.Add(new CTienda() { Ico = new BitmapImage(new Uri("img/azure.png", UriKind.Relative)), Nombre = "AZURE", Precio = 250 });
    
    ---
    --
                
    
                cmbLista.ItemsSource = tienda;
                dtpPf.Value = DateTime.Today;
                dtpPf_ValueChanged(null, null);
    
    
            }
    
    //EVENT
    txbSalida.Text = "";
                CTienda ct = (CTienda)cmbLista.SelectedItem;
                if (ct == null) return;
    
               
    
    double total = ct.Precio + ct.Precio * 10/100;
    txbSalida.Text = precio.ToString("C"); 


    Monday, January 27, 2014 1:47 AM