I'm trying to filter the content based on some buttons like this
I have the XAML setup as this
<CollectionView Grid.Row="0"
ItemsSource="{Binding Categories}"
ItemsLayout="HorizontalList"
Margin="20,0"
x:Name="els">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<Button Style="{StaticResource ButtonOutline}" Text="{Binding .}" FontSize="20" Margin="5,10"
Clicked="CategorySelected"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
And my Page has the following method for the event, the idea is to change the style of the button that was clicked
private void CategorySelected(object sender, EventArgs e)
{
var btn = (Button)sender;
btn.TextColor = Color.Parse("#FFFFFF");
viewModel.ChangeCategory(btn.Text);
}
Everything is working as expected, but I can't seem to find a way to change the style of all the other buttons that weren't clicked. How can I have access to them? I have access to the CollectionView in my code, but I'm not able to access the Children variable that I can in debug mode (after going to base multiple times), I've tried all types of casting, but no success
Is there a way to reach those children? Or maybe another solution that is more MVVM like
If someone has the same issue, I would advise to checkout this project on Github, he solves this perfectly maui-starbucks-ui