예제 #1
0
        void BotonParaSalvar(object sender, EventArgs e)
        {
            // Si en Titulo no hay texto, no te dejará guardar
            if (String.IsNullOrWhiteSpace(entrada.Text))
            {
                DisplayAlert("Error", "La nota debe tener título", "OK");
                return;
            }

            var lista = GestorNotas.LeerNotas();

            if (_item == null)
            {
                //item es nuevo
                _item = new Nota()
                {
                    Titulo    = entrada.Text,
                    Contenido = editor.Text
                };
                GestorNotas.CrearNota(_item);
            }
            else
            {
                //si no, actualizamos el item de la lista
                _item.Titulo    = entrada.Text;
                _item.Contenido = editor.Text;
                GestorNotas.ActualizarNota(_item);
            }
        }
예제 #2
0
        private void ButtonBorrar(object sender, EventArgs e)
        {
            var button = sender as Button;

            if (button != null)
            {
                //lo ha podido castear o convertir
                var grid           = button.Parent as Grid;
                var viewcell       = grid.Parent as ViewCell;
                var bindingContext = viewcell.BindingContext;
                var nota           = bindingContext as Nota;
                var lista          = GestorNotas.BorrarNota(nota);
                listadoNotas.ItemsSource = lista;
            }
        }