Hiding items in Monotouch dialog section - height does not change

I have a Monotouch dialog with 5 items.

When the condition is true, I need to hide items 1-4 and show item 5. When it is false, I need to show Items 1-4 and hide item 5.

The elements disappear, but the height of the section does not change. I've tried all the usual, such as ReloadData

, ReloadTableView

and Reload

on DialogViewController.

The only method I can see that will cause the height to change is RemoveRange

in the section and I don't want to add and remove items

How do I get the section to close when the items are hidden?

+3


source to share


1 answer


UPDATE

Found a better way to hide Monotouch Dialog (MT D) elements and change their height.

Create your own class that inherits from the MT D element you are working with

public class DateElement : CrossUI.Touch.Dialog.Elements.DateElement, IElementSizing

      

And implement the IElementSize GetHeight interface

public nfloat GetHeight(UITableView tableView, Foundation.NSIndexPath indexPath)
{
    if (this.Visible == false)
    {
        return 0;
    }
    else
    {
        return 44.0f;
    }
}

      



As long as the DialogViewController is marked with UnevenRows, elements that implement IElementSize will receive a GetHeight call. When the element is not showing, just return 0.

Some elements already have the GetHeight function implemented, so you can call the base implementation when the element is visible. In other cases, you will have to implement something yourself. It can be hardcoding a fixed size or measuring caption and detail text.

The only way I could "hide and show" was to remove and insert elements when needed.

We are using MVVMCross and I have bound to the ViewModel property to control the visibility. Now I am using MvxPropertyChangedListener

and listening to the same properties that were previously linked.

Now when the property changes, I call the Delete and Insert methods on the section. Not what I wanted, but it works.

+2


source







All Articles