I need help with: searching through a list of buttons

Hello, I would like to search through a list of buttons. I tried to use your video for that purpose too but I didnt fingured it out how to do it with buttons.
here is my code.
private readonly List exercisesList = new List();
public example()
{
//Searchbar.
SearchBar searchBar = new SearchBar();
Button button= new Button { Image = “icon”, Text = “Biceps Curl”, HorizontalOptions = LayoutOptions.Fill,
};
//Searchbar function.
searchBar.SearchButtonPressed += (sender, args) =>
{
string keyWord = searchBar.Text; IEnumerable searchResult = exercisesList.Where(button => button.Text.ToLower().Contains(keyWord.ToLower()));
};
//Defining the StackLayout.
StackLayout stackLayout = new StackLayout
{
Padding = new Thickness(5,Device.OnPlatform(0,20,0), 5, 0),
};
//Adding the views to the stackLayout.
stackLayout.Children.Add(heading);
stackLayout.Children.Add(searchBar);
stackLayout.Children.Add(listview);
Content = new ScrollView
{
Content = stackLayout, };
};
Additional information;
The listview doesnt shows real buttons just a text that says: “xamarin.forms.Button”. If I click on it nothing happens- the searching functions(I know the text of the button and then I search it and its been found) but the button has no function and isnt a button it looks like a normal label
Thanks in regards!

Sign In or Register to comment.