It is possible to make a menu with sub items?
Root = new TableRoot();
var tableSection = new TableSection("Menu");
foreach (var item in data)
{
//var topLevelCell = new MenuItemstyle(item);
//topLevelCell.Command = new Command(async () => { await Navigation.PushAsync((Page)Activator.CreateInstance(item.TargetType)); });
//tableSection.Add(topLevelCell);
tableSection.Add(new TextCell()
{
Text = item.title,
TextColor = item.color,
Command = new Command(async () => { await Navigation.PushAsync((Page)Activator.CreateInstance(item.TargetType)); })
});
foreach (var sub in item.subSections)
{
tableSection.Add(new MainMenuSubCell()
{
Text = sub.title,
TextColor = sub.color,
StyleId = "sub",
Command = new Command(async () => { await Navigation.PushAsync((Page)Activator.CreateInstance(item.TargetType)); })
});
}
}
Root.Add(tableSection);
I am trying this along with:
class MainMenuSubRenderer : TextCellRenderer
{
protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Context context)
{
var cell = (LinearLayout)base.GetCellCore(item, convertView, parent, context);
var textCell = (TextView)(cell.GetChildAt(1) as LinearLayout).GetChildAt(0);
//textCell.SetHeight(10);
textCell.SetPadding(35, 0, 0, 0);
textCell.SetTextSize(Android.Util.ComplexUnitType.Pt, 5);
return cell;
}
}
And i get weird behavior , I am only apply padding and text size to sub menu items but the top level items are RANDOMLY picking up the padding and size... It changes as i scroll the menu ie table.