public void EventHandler_Agregar(object sender, EventArgs e)
        {
            Button  btnCurrent      = (sender as Button);
            ListBox lbxInfraDetalle = currentExpander.FindName("lbx_childExpander") as ListBox;

            Grid        gridExpander     = currentExpander.FindName("gridExpander") as Grid;
            Expander    expanderAgregar  = currentExpander.FindName("expanderAgregar") as Expander;
            TextBox     txt_tamano       = gridExpander.FindName("textBox") as TextBox;
            RichTextBox rtbx_descripcion = gridExpander.FindName("richTextBox") as RichTextBox;

            Model.Infraestructura_Detalle nuevoInfraDetalle = new Model.Infraestructura_Detalle()
            {
                Id_Infra    = btnCurrent.Tag.ToString(),
                Tamano      = txt_tamano.Text,
                Descripcion = GetString(rtbx_descripcion)
            };

            if (LocalDataStore.GuardarDetalleInfraestructura(nuevoInfraDetalle))
            {
                lbxInfraDetalle.ItemsSource = LocalDataStore.GetInfraestructuraDetalle(btnCurrent.Tag.ToString());
                lbxInfraDetalle.Items.Refresh();
                MessageBox.Show("Se guardo exitosamente", "Registro de Detalle Infraestructura", MessageBoxButton.OK, MessageBoxImage.Information);
                txt_tamano.Text = "";
                FlowDocument fd = new FlowDocument();
                fd.Blocks.Add(new Paragraph(new Run("")));
                rtbx_descripcion.Document  = fd;
                expanderAgregar.IsExpanded = false;
            }
            else
            {
                MessageBox.Show("No se guardo", "Registro de Detalle Infraestructura", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Ejemplo n.º 2
0
        private void Expander_Expanded(object sender, RoutedEventArgs e)
        {
            Expander expander = sender as Expander;
            Slider   s        = expander.FindName("Slider") as Slider;
            TextBox  min      = s.FindName("MinVal") as TextBox;
            TextBox  max      = s.FindName("MaxVal") as TextBox;

            if (min != null && max != null && s.DataContext is VariableElement element)
            {
                s.Value  = ((Fraction)element.VariableValue).GetValue();
                min.Text = ((int)s.Value - 10).ToString();
                max.Text = ((int)s.Value + 10).ToString();
            }
        }