dotnet / dotnet/maui

Multi attach a same Style with AdaptiveTrigger

Open
#11,030 4 comments 0 reactions 0 assignees View on GitHub
area-xaml platform/android platform/windows s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

![image](https://user-images.githubusercontent.com/40793353/199188014-68f56109-5af5-4482-b720-915880b16be3.png)

Only last element successful to attach with Style.

I tried using x:Key with Style={StaticResource }
![image](https://user-images.githubusercontent.com/40793353/199188487-fe156f24-6acc-4496-9028-7b2feb89d8c3.png)

I wondered whether is element issues. So I tried to replace BoxView, StackLayout, and etc with Label and get same result.

It will work fine if property write it to element one by one.
It will work fine if I control the property into .cs file.
It will work fine if multi attach a same Style with other Trigger such as OrientationStateTrigger and DeviceStateTrigger.

### Steps to Reproduce

1. Create a Maui Project (No matter .Net6 / .Net7)
2. Go to App.cs change the code ( MainPage = new MainPage(); )
3. Go to MainPage.xaml.cs and Remove whole content in scrollview and Write the code at above
4. Build it in Android emulator
(Galaxy Nexus for testing MinWindowWidth = 360 )
(Tablet M-DPI 7'' for testing MinWindowWidth = 600)

### Link to public reproduction project repository

https://github.com/inpro160/NewAppNet7

### Version with bug

7.0 Release Candidate 1

### Last version that worked well

Unknown/Other

### Affected platforms

Android, Windows

### Affected platform versions

Android10, Window11, I didn't test on other platforms.

### Did you find any workaround?

No

### Relevant log output

```shell
No
```

Contributor guide

Open the contributing guide

Research direction

Start with the public reproduction project and the App.cs and MainPage.xaml.cs entry points, then run the AdaptiveTrigger case on the Android emulator and Windows. Compare applying one shared Style to multiple elements with the working OrientationStateTrigger and DeviceStateTrigger cases. Done means the same Style applies successfully to every target element across the reported platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop-dev, frontend, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.