c# - Xamarin.Forms (iOS) - How to change the text of the SearchBar "Cancel" button? -
we internationalizing mobile app team developing, , noticed "cancel" button in searchbar not translating (everything else translating fine) - says "cancel" in english no matter language change ipad simulator to. if can set text myself, can ensure it's internationalized properly. so...
how change "cancel" button text on xamarin.forms searchbar? i've tried custom renderer, having difficulty targeting cancel button subview. this answer seems great job of explaining how in objective c, i'm having trouble translating c# within xamarin.forms framework.
create new custom renderer ios. customsearchbarrenderer , subclass xamarin's original searchbarrenderer
public class customsearchbarrenderer : searchbarrenderer { } i'd try override onelementchanged method , set custom title after base class has done work. this:
protected override void onelementchanged(elementchangedeventargs<searchbar> e) { base.onelementchanged(e); var cancelbutton = control.finddescendantview<uibutton>(); cancelbutton.title = "whatever"; } edit: please aware cancelbutton might recreated @ point might have set title @ other point too. however, should starting point.
you can take @ current searchbarrenderer implementation here.
Comments
Post a Comment