Forum Xamarin.Forms

Add public GetCommandBar method to IToolbarProvider renderers on UWP

DanielHindrikesDanielHindrikes SEMember ✭✭
edited July 2017 in Xamarin.Forms

This is platform specific change that not will affect Xamarin.Forms.Core, it this is the wrong way to propose the change, please tell me how to do it the correct way.


TabbedPageRenderer has a public method for getting CommanBar. I want to add a method for that in NavigationPageRenderer and MasterDetailPageRenderer as well. The change will make that all renderers that implement the IToolbarProvider interface will be more similar to each other.

API Changes

This method to be added in NavigationPageRenderer.cs and MasterDetailPageRenderer in Xamarin.Forms.Platform.UAP.
public Task<CommandBar> GetCommandBarAsync() { return ((IToolbarProvider)_container)?.GetCommandBarAsync(); }

In NavigaitonPagerRenderer the keyword virtual needs to be added to the declaration of OnElementChanged.

Intended Use Case

The idea of this change came up when I wanted to add a SearchBar to the CommandBar for a UWP app. I want to do that by accessing the CommandBar.Content property. For an iOS app, it's easy to achieve this while you easily can access the NavigationBar. This change will make it possible to easily do that on UWP as well.


Open · Last Updated

Sign In or Register to comment.