Note that there are some explanatory texts on larger screens.

plurals
  1. POCommitEditingStyle of Monotouch.Dialog RootElement
    text
    copied!<p>I have created my own DialogViewController class. The dialog has two levels. I want the user to be able to click an edit button that allows him to remove the elements on the second level.</p> <p>Let me try to explain with some code:</p> <pre><code>public class TestMenu : DialogViewController { public TestMenu() : base (new RootElement("Menu"), true) { Section section = new Section (); this.Root.Add (section); RootElement firstRoot = new RootElement ("First level 1"); section.Add (firstRoot); RootElement secondRoot = new RootElement ("First level 2"); section.Add (secondRoot); // first rootelement Section firstSection = new Section (); firstRoot.Add (firstSection); StringElement firstElement = new StringElement ("Second level element 1"); firstSection.Add (firstElement); // Button to set edit mode Section buttonSection = new Section (); firstRoot.Add (buttonSection); StringElement buttonElement = new StringElement ("Edit"); buttonElement.Tapped += delegate { // This works to get it in editing mode firstRoot.TableView.SetEditing(true, true); // This statement will not set it to editing mode //this.SetEditing(true, true); }; buttonSection.Add (buttonElement); // second rootelement Section secondSection = new Section (); secondRoot.Add (secondSection); StringElement secondElement = new StringElement ("Second level element 2"); secondSection.Add (secondElement); } public override Source CreateSizingSource (bool unevenRows) { return new TestSource(this); } class TestSource : DialogViewController.SizingSource { public TestSource(DialogViewController container) : base (container) {} public override bool CanEditRow (UITableView tableView, NSIndexPath indexPath) { return true; } public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath) { // This is only fired when something is deleted in the first level base.CommitEditingStyle (tableView, editingStyle, indexPath); } } } </code></pre> <p>When the user clicks on the Edit cell the table is set in edit mode.</p> <p>Clicking on the delete icons of course does nothing. How can I enable edit mode or swipe to show the delete button on the root elements in the second level and onwards?</p> <p>I have read the following post that explains how to enable the edit mode in the dialog view controller first screen: <a href="http://monotouch.2284126.n4.nabble.com/Monotouch-Dialog-table-rows-not-selectable-in-edit-mode-td4658436.html" rel="nofollow">http://monotouch.2284126.n4.nabble.com/Monotouch-Dialog-table-rows-not-selectable-in-edit-mode-td4658436.html</a></p> <p>This works for the first level, but it is also possible to sublass the Source in the same way in the second level (Second level element 1)?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload