Hi dojo,
I'm running into a strange issue and could use your insight.
In my RemoveField method, I'm currently calling RemoveWidget for each widget in the selected section.
This works— all widgets are successfully removed—though I realize it's not the most efficient approach.
While reviewing the documentation, I came across the Clear()
method, which seems ideal for this use case.
However, when I replace my current code with section.Clear(), nothing happens. I trigger the same button click as before, but the section remains unchanged—none of the widgets are removed.
Any idea what I might be missing?
Thanks in advance for your help!
Looking at your code, and implying that you view instance is a Dialog, you're removing the widgets from the Dialog, while the Section.Clear() only clears the widgets from the Section. If you have added the Section beforehand to the Dialog, the widgets of the Section will still be part of that Dialog.
Like Timothy mentioned, I would rebuild my Dialog after clearing the widgets from the Section or you keep using your own method, there's nothing wrong with it.
A rebuild of the Dialog could look like this:
private void BuildUi() {
Clear();
AddWidget(new Label("This is a label"), 0, 0);
AddSection(sectionThatWasCleared, 1, 0);
}