dotnet / dotnet/maui-samples

Setting BackgroundColor of AnimalTemplate, disables the backgroundColor style of the grid element

Open
#426 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

**Repo**: https://github.com/dotnet/maui-samples/tree/main/8.0/Fundamentals/Shell

When I set the `Background|BackgroundColor` property for DataTemplate "AnimalTemplate":
**App.xaml:**

```



<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="Green" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>


```

`AnimalTemplate` is the `ItemTemplate` for the `CollectionView`.

**Result:**
Items' BackgroundColor doesn't change.

**Expected Result:**
Selected items'backgroundColor changes to green background.

---

**Repro:**
1. Add Background="Pink" to DataTemplate x:Key="AnimalTemplate" in `App.xaml`
2. Run the app
3. Select a cat
4. Navigate back to CatsPage.xaml

The previously selected cat is in selected state, but backgroundColor didn't change.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.