ToolbarItems - Want to be able to Display/Not Display using a variable in code behind

Riffy100

Member
Joined
Jul 24, 2021
Messages
11
Programming Experience
Beginner
Hi

I am using VS 2022/XAML/C#

I have a ToolbarItem in my xaml ContentPage as follows:

<ContentPage.ToolbarItems>
<ToolbarItem Text="Item"/>
</ContentPage.ToolbarItems>

What I would like to be able to do in my ViewModel code is be able to use a boolean variable to decide when to display or not display the Toolbar item.

The IsEnabled property is available but my understanding is that it is not implemented.

II know there is the ToolbarItems.RemoveAt and ToolbarItems.Add commands, but not sure where best to introduce them for xaml contentpage to work.

Can someone please help me in writing code behind using boolean variable DisplayItem (true/false) to toggle on/off the ToolbarItem.

Please let me know if you need further details.

Thanks
 
Last edited:
Back
Top Bottom