Hello, I finally found the solution in the Apple documentation. I need to make the rows selectable when in edit mode with the allowsSelectionDuringEditing property of UITableView. Thanks! _jmgomez_ Juan M Gómez
2012/11/5 Juan Manuel Gómez Álvarez <[email protected]> > Hello Miguel, > > I followed the approach in your example of DemoEditingAdvanced (I updated > the Root and then called ReloadData). > > In your example below (modified to illustrate the error) I try to trigger > the selected element when the rows are editing but it doesn't work. > Allthough it works without editing it. > > Thank you, > _jmgomez_ > Juan M Gómez > > void AdvancedConfigEdit (DialogViewController dvc) > > { > > dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem > (UIBarButtonSystemItem.Edit, delegate { > > // Activate editing > > // Switch the root to editable elements > > dvc.Root = CreateEditableRoot(dvc.Root, true); > > dvc.ReloadData(); > > // Activate row editing & deleting > > dvc.TableView.SetEditing (true, true); > > AdvancedConfigDone(dvc); > > } ); > > } > > void AdvancedConfigDone (DialogViewController dvc) > > { > > dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem > (UIBarButtonSystemItem.Done, delegate { > > // Deactivate editing > > dvc.ReloadData(); > > // Switch updated entry elements to StringElements > > dvc.Root = CreateEditableRoot(dvc.Root, false); > > dvc.TableView.SetEditing (false, true); > > AdvancedConfigEdit (dvc); > > > } ); > > } > > RootElement CreateEditableRoot (RootElement root, bool editable) > > { > > var rootElement = new RootElement("Todo list") { > > new Section() > > } ; > > foreach (var element in root[0].Elements) { > > if(element is StringElement) { > > rootElement[0].Add(CreateEditableElement (element.Caption, > (element as StringElement).Value, editable)); > > } else { > > rootElement[0].Add(CreateEditableElement (element.Caption, > (element as StringElement /*I'M ADDING THIS */).Value, editable)); > > } > > } > > return rootElement; > > } > > Element CreateEditableElement > (string caption, string content, bool editable) > > { > > return new StringElement(caption, > ()=>{new UIAlertView("","",null,"").Show();}); //I'M ALSO ADDING THIS > > > if (editable) { > > return new EntryElement(caption, "todo", content); > > } else { > > return new StringElement(caption, content); > > } > > > } > > > Juan M Gómez Álvarez > > > 2012/11/5 Miguel de Icaza <[email protected]> > >> Your approach would only work if you reload the entire tree (call >> CreateEditableCourts again, and replace the root with the new value). >> >> Miguel >> >> On Sun, Nov 4, 2012 at 10:56 AM, Juan Manuel Gómez Álvarez < >> [email protected]> wrote: >> >>> Hello, >>> >>> I´m using MonoTouch.Dialog to make an editable ViewTable like the Alarm >>> app. I use two different Element, one when I don't edit (RadioElement) and >>> another when I am in edit mode (StringElement). >>> >>> private RootElement CreateEditablCourts (bool editable=false) >>> >>> { >>> >>> >>> var root = editable? new RootElement("Juzgados") : new RootElement( >>> "Juzgados",new RadioGroup(-1)); >>> >>> var section = new Section (); >>> >>> var courts = lawerData.getAllCourts(); >>> >>> foreach (var c in courts) { >>> >>> var court = c; >>> >>> section.Add(CreateEditableElement(court.Location,editable)); >>> >>> } >>> >>> root.Add(section); >>> >>> >>> return root; >>> >>> } >>> >>> >>> private Element CreateEditableElement (string caption, bool editable = >>> false) >>> >>> { >>> >>> if (editable) >>> >>> return new StringElement (caption, () => { >>> >>> new UIAlertView ().Show ();}); //NEVER TRIGGER >>> >>> >>> var radioElement = new RadioElement(caption,string.Empty); >>> >>> radioElement.Tapped+= () => { >>> new UIAlertView ().Show (); //WORKS >>> >>> } ; >>> >>> >>> return radioElement; >>> >>> >>> } >>> >>> >>> Thanks in advance, >>> _jmgomez_ >>> Juan M Gómez >>> >>> >>> _______________________________________________ >>> MonoTouch mailing list >>> [email protected] >>> http://lists.ximian.com/mailman/listinfo/monotouch >>> >>> >> >
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
