Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms Toolbaritems UWP not showing properly

while following this tutorial https://xamarinhelp.com/xamarin-forms-toolbar/ I came across a little problem, the items are well displayed on Android, but on UWP toolbar is closed causing items to be "collapsed" thus hiding "items names" and leaving only a rectangle for the button, in order to show "Name" of each item I need to click the Ellipsis button (three dots that open the list of secondary items). Is there a way to to solve this?

<ContentPage.ToolbarItems >
    <ToolbarItem Name="MenuItem1" Order="Primary" Text="Bases" Priority="3"/>
    <ToolbarItem Name="MenuItem2" Order="Secondary"  Text="Numericos" Priority="1"/>
    <ToolbarItem Name="MenuItem2" Order="Secondary"  Text="Sistema Internacional" Priority="1"/>
</ContentPage.ToolbarItems>

Blank Space Open toolbar

like image 755
David Melara Avatar asked Oct 16 '25 17:10

David Melara


1 Answers

This is, because the default setting for the IsOpen property of the CommandBar in UWP, is Closed. Meaning you will only see icons ( and the labels beneath the icons are hidden ). If you set that property to True, the names will be displayed.

See ref Open and Closed states here https://learn.microsoft.com/en-us/windows/uwp/controls-and-patterns/app-bars And detail info about the property here https://learn.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.AppBar#Windows_UI_Xaml_Controls_AppBar_IsOpen

For you to control this, there are several options. I would suggest a Xamarin Effect to control the property and attach that to the toolbar. Or create a custom renderer so that each toolbar is open by default.

like image 173
Depechie Avatar answered Oct 18 '25 13:10

Depechie