I have a Monotouch Dialog Section with 5 Elements.
When a condition is True I need to hide Elements 1-4 and show Element 5. When it is false I need to show Elements 1-4 and hide Element 5.
The Elements disappear but the Section height does not change. I have tried all the usuals such as ReloadData
, ReloadTableView
, and Reload
on the DialogViewController.
The only method I can see that will cause the height to change is RemoveRange
on the Section and I do not want to have to add and remove the Elements
How do I get the Section to close up when the Elements get hidden?
UPDATE
Found a better way of hiding Monotouch Dialog (MT D) Elements and have their height change.
Create a custom class that inherits from the MT D element you are working with
And implement the IElementSizing Interface's GetHeight
As long as the DialogViewController is marked a having UnevenRows the elements implementing IElementSizing will have their GetHeight called. When the element is not visible simply return 0.
Some elements have GetHeight already implemented so you can call the base implementation when the element is Visible. Other times you will have to implement something yourself. This can be hardcoding a fixed size or measuring the Caption and Detail text.
The only way I could "hide and show" Elements was to Remove and Insert elements when needed.We are using MVVMCross and I was binding to a ViewModel property to control the Visibility. Now I am using anMvxPropertyChangedListener
and listening for the same property that was previously being bound.Now when the property changes I call Remove and Insert methods on the Section. Not what I wanted but it works.