Search code examples
xamarin.formssearchbarcustom-renderer

Xamarin.Forms: SearchBar font size on windows phone


I have a problem with styling the SearchBar for Windows phone. The font size is just unbearably huge and there is not property I can set directly. I've read a bit upon custom renederers (though I believe that's just overkill if I jsut wanted to set font size imho) but I really don't know how to even begin and it's the only thing now that's holding me back from being able to deploy to Windows Phone. I tried searching for it but uncle Google sadly let me down on this one. Any help is of course greatly appreciated.

Screenshot:

Screenshot


Solution

  • if you are using xaml then you can control style for different platforms like this:

    <SearchBar x:Name="Search"
               Placeholder="Search"    
               TextChanged="SearchBar_OnTextChanged"  
               SearchButtonPressed="OnSearch" BackgroundColor="#19588F">
             <SearchBar.FontSize>
                 <OnPlatform x:TypeArguments="x:Double"
                             WinPhone="10"
                             Android="22"
                             iOS="20" />
             </SearchBar.FontSize>
     </SearchBar>