I'm adding toolbar item
to the Page.ToolbarItems
list, but I would like to add a line separator between certain toolbar item
. I could add a new toolbar item
with an image of a line, but I would need to prevent any Action
when the line is pressed and it won't allow me to use null
. It would also look less than ideal.
Note that that each ToolbarItem
is added through the C# code, not through Xaml.
Here is some pseudo code as an example of what I have now:
if(!ToolbarItems.Any())
{
ToolbarItems.Add(new ToolbarItem("Page 1", null, NavigateToPage1(), ToolbarItemOrder.Secondary, 0);
ToolbarItems.Add(new ToolbarItem("Page 2", null, NavigateToPage2(), ToolbarItemOrder.Secondary, 0);
// <Insert Separator Here>
if(boolVal) {
ToolbarItems.Add(new ToolbarItem("Page 3", null, NavigateToPage3(), ToolbarItemOrder.Secondary, 0);
}
ToolbarItems.Add(new ToolbarItem("Page 4", null, NavigateToPage4(), ToolbarItemOrder.Secondary, 0);
ToolbarItems.Add(new ToolbarItem("Page 5", null, NavigateToPage5(), ToolbarItemOrder.Secondary, 0);
// <Insert Separator Here>
ToolbarItems.Add(new ToolbarItem("Page 6", null, NavigateToPage6(), ToolbarItemOrder.Secondary, 0);
}
Strictly speaking, you can't.
ToolbarItems
map to specific controls in iOS and Android which don't provide the capability that you want to have, so even if you go into writing the custom renderers it is not possible because native platforms don't allow this.
Speaking a bit more widely if you use TitleView
then you can put into the header whatever you want and then you can make it look like what you wanted but that isn't a precise answer to your question as you wouldn't use ToolbarItems
in that case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With