xamarin/Xamarin.Forms

[Shell] Unable to set text outside constructor and OnAppearing in search bar

Open

#8,237 opened on Oct 25, 2019

 (1 comment) (2 reactions) (0 assignees)C# (1,926 forks)batch import
a/shell :shell:e/3 :clock3:help wantedinactivet/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

Is not possible to set a text in search bar of shell menu outside the constructor and OnAppearing methods.

OBSERVATION: In this example, I tested the monkeys page. ShellSearchBarTextIssue.zip

Steps to Reproduce

  1. In <Shell.SearchHandler> tag of the page set a name for the Search Handler control (x:name), for example x:name="searchTest".
  2. In the .cs file override the OnAppearing method set the query property of the search handler, for example searchTest.Query="Test". It works well as expected.
  3. Repeat the step 2 for the constructor of the .cs file.
  4. Create a button anywhere on the page and create a click event.
  5. Set the query property of the search handler in the click event, for example searchTest.Query="Test";.

Expected Behavior

The search bar displays the text setting in the click event.

Actual Behavior

The search bar does not show the text setted.

Basic Information

  • Version with issue: Xamarin.forms.dll 4.3.0.908675
  • Last known good version: 4.3.0.908675
  • IDE: Visual Studio Professional 2019.
  • Platform Target Frameworks:
    • Android: API 22 above.
  • Android Support Library Version: 5.1 above.
  • Nuget Packages: Xamarin.Forms.dll 4.3.0.908675
  • Affected Devices: Samsung Galaxy S6, S7, S8 Plus, S10 plus, Motorola Moto E Play.

Screenshots

Reproduction Link

https://github.com/JeysonGustavo/ShellSetSearchText

Take a look at the MonkeysPage

Contributor guide