Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ThemeResource bindings are not scope-updated on Style switch #13016

Merged
merged 5 commits into from
Jul 27, 2023

Conversation

MartinZikmund
Copy link
Member

@MartinZikmund MartinZikmund commented Jul 26, 2023

GitHub Issue (If applicable): closes #12496

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

Previously only StaticResource bindings were re-evaluated when Style was applied. This is not enough as ThemeResources also need to be sourced from the current scope. In addition, the precedence override needs to be applied only while the setters are being applied, but not for the resource bindings update, otherwise it could also apply base control bindings with ExplicitStyle precedence, even though the bindings have just ImplicitStyle precedence.

What is the new behavior?

Fixed!

Copilot Summary

🤖 Generated by Copilot at e51e120

This pull request fixes a bug and adds a test for theme resource resolution in styles. It refactors the Style.ApplyTo method to make it more clear and consistent. It also creates a new user control with two styles for a button, one using a theme resource and one using a static resource, and a new test method that asserts that the button's background color changes correctly when the style is switched at runtime.

PR Checklist

Please check if your PR fulfills the following requirements:

@Xiaoy312
Copy link
Contributor

this should be a backport candidate for 4x

@MartinZikmund
Copy link
Member Author

@Xiaoy312 yes, backport will follow up after it is merged 👍

@agneszitte
Copy link
Contributor

formatting issue @MartinZikmund
src\Uno.UI\UI\Xaml\Style\Style.cs(86,1): Error IDE0055: Fix formatting

@nventive-devops
Copy link
Contributor

The build 87407 found UI Test snapshots differences: android-28-net7: 0, android-28-net7-Snap: 61, ios: 34, ios-Snap: 92, skia-gtk-screenshots: 15, skia-wpf-screenshots: 13, wasm: 32, wasm-automated-net7.0-UWP-Benchmarks: 0, wasm-automated-net7.0-UWP-Default: 40, wasm-automated-net7.0-UWP-RuntimeTests: 0, wasm-automated-net7.0-WinUI-RuntimeTests: 0

Details
  • android-28-net7: 0 changed over 1

  • android-28-net7-Snap: 61 changed over 1041

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Default_UITests_Windows_UI_Xaml_Controls_TextBox_TextBox_IsTabStop_UITests_Windows_UI_Xaml_Controls_TextBox_TextBox_IsTabStop
    • ListView_ListView_With_ListViews_Count_Measure_UITests_Shared_Windows_UI_Xaml_Controls_ListView_ListView_With_ListViews_Count_Measure
    • MediaPlayerElement_MediaPlayerElement_Stretch_Fill_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Stretch_Fill
    • Pickers_UITests_Windows_UI_Xaml_Controls_CalendarView_CalendarView_Theming_UITests_Windows_UI_Xaml_Controls_CalendarView_CalendarView_Theming
    • Default_SamplesApp_Wasm_Windows_UI_Xaml_Controls_ListView_ListView_IsSelected_SamplesApp_Wasm_Windows_UI_Xaml_Controls_ListView_ListView_IsSelected
    • Default_UITests_Windows_UI_Xaml_Controls_ToolTip_ToolTip_Long_Text_UITests_Windows_UI_Xaml_Controls_ToolTip_ToolTip_Long_Text
    • Default_UITests_Windows_UI_Xaml_DragAndDrop_DragDrop_TestPage_UITests_Windows_UI_Xaml_DragAndDrop_DragDrop_TestPage
    • ListView_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListView_VirtualizePanelAdaptaterIdCache_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListView_VirtualizePanelAdaptaterIdCache
    • ScrollViewer_UITests_Windows_UI_Xaml_Controls_ScrollViewerTests_ScrollViewer_Padding_UITests_Windows_UI_Xaml_Controls_ScrollViewerTests_ScrollViewer_Padding
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromMsAppData_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_FromMsAppData
    • Scrolling_ScrollViewer_Simple_UITests_Shared_Windows_UI_Xaml_Controls_ScrollViewerTests_ScrollViewer_Simple
    • Brushes_ImageBrushShapeStretchesAlignments_UITests_Windows_UI_Xaml_Media_ImageBrushTests_ImageBrushShapeStretchesAlignments
    • ColorPicker_ColorPickerSample_UITests_Microsoft_UI_Xaml_Controls_ColorPickerTests_ColorPickerSample
    • ColorPicker_WinUIColorPickerPage_UITests_Shared_Microsoft_UI_Xaml_Controls_ColorPickerTests_WinUIColorPickerPage
    • DragAndDrop_UITests_Windows_UI_Xaml_DragAndDrop_DragDrop_ListView_Custom_States_UITests_Windows_UI_Xaml_DragAndDrop_DragDrop_ListView_Custom_States
    • Image_ImageSourceStream_Uno_UI_Samples_UITests_ImageTestsControl_ImageSourceStream
    • Grid_CenteredGridinGridwiththreefixedsizechildren_Uno_UI_Samples_Content_UITests_GridTestsControl_CenteredGridinGridwiththreefixedsizechildren
    • ListView_ListViewWithinScollViewer_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewWithinScollViewer
    • ListView_ListView_ChangeView_UITests_Shared_Windows_UI_Xaml_Controls_ListView_ListView_ChangeView
    • Slider_Slider_Inside_ScrollViewer_Uno_UI_Samples_Content_UITests_Slider_Slider_Inside_ScrollViewer
  • ios: 34 changed over 270

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • TextBox_UpdatedBinding_On_OneWay_Mode_UITests_Windows_UI_Xaml_Controls_TextBox_TextBox_Bindings
    • ListView_ChangingText_Validation_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListView_Changing_Text
    • ListView_SelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • ProgressRing_Visibility_Collapsed_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • Screenshots_Image_Stretch_Alignment_Taller_Mode-2
    • ListView_SelectedItem_Both_Selection_Changed
    • Screenshots_Image_Stretch_Algmnt_Inf_Vertical_Mode-1
    • Screenshots_Image_Stretch_Algmnt_Inf_Vertical_Mode-2
    • Screenshots_Image_Stretch_Alignment_Wider_Mode-2
    • Screenshots_Image_Stretch_Alignment_Wider_Mode-3
    • Keyboard_Textbox_NoScrollViewer_Validation_5_-_Remove_Focus_on_numberTextBox
    • ListView_ObservableCollection_Creation_Count_Added_above
    • Screenshots_Image_Stretch_Alignment_Wider_Mode-1
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • Screenshots_Image_Stretch_Alignment_Equal_Mode-3
    • ContentPresenter_Template_Uno_UI_Samples_Content_UITests_ContentPresenter_ContentPresenter_Template
    • Keyboard_Textbox_NoScrollViewer_Validation_1_-_Remove_Focus_on_filledTextBox
    • ListView_ObservableCollection_Creation_Count_Scrolled1
    • ListView_ObservableCollection_Creation_Count_Removed_above
    • ListView_ObservableCollection_Creation_Count_Scrolled2
  • ios-Snap: 92 changed over 1032

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Brushes_UITests_Shared_Windows_UI_Xaml_Media_ImageBrushTests_ImageBrush_SameWithDelay_UITests_Shared_Windows_UI_Xaml_Media_ImageBrushTests_ImageBrush_SameWithDelay
    • Buttons_AppBarToggleButtonTest_Uno_UI_Samples_Content_UITests_ButtonTestsControl_AppBarToggleButtonTest
    • SwipeControl_MUXControlsTestApp_SwipeControlPage2_MUXControlsTestApp_SwipeControlPage2
    • ComboBox_ComboBox_NativePopup_SamplesApp_Wasm_Windows_UI_Xaml_Controls_ComboBox_ComboBox_NativePopup
    • ContentControl_ContentControl_Inheritance_Uno_UI_Samples_Content_UITests_ContentControlTestsControl_ContentControl_Inheritance
    • Image_ImageSourceUrlMsAppxScheme_Uno_UI_Samples_UITests_ImageTests_ImageSourceUrlMsAppxScheme
    • NumberBox_UITests_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBox_Description_UITests_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBox_Description
    • ComboBox_ComboBox_ScrollViewer_SamplesApp_Wasm_Windows_UI_Xaml_Controls_ComboBox_ComboBox_ScrollViewer
    • ContentControl_ContentControl_SetNull_Uno_UI_Samples_Content_UITests_ContentControlTestsControl_ContentControl_SetNull
    • TextBlock_UITests_Windows_UI_Xaml_Controls_TextBlockControl_TextBlock_TextTrimming_UITests_Windows_UI_Xaml_Controls_TextBlockControl_TextBlock_TextTrimming
    • TextBlock_Uno_UI_Samples_Content_UITests_TextBlockControl_TextBlock_Special_Character_Uno_UI_Samples_Content_UITests_TextBlockControl_TextBlock_Special_Character
    • TextBox_Input_InputScope_Email_Uno_UI_Samples_Content_UITests_TextBoxControl_Input_InputScope_Email
    • Border_UITests_Shared_Windows_UI_Xaml_Controls_BorderTests_Border_CornerRadius_Toggle_UITests_Shared_Windows_UI_Xaml_Controls_BorderTests_Border_CornerRadius_Toggle
    • Brushes_UITests_Windows_UI_Xaml_Media_ImageBrushTests_ImageBrush_Formats_UITests_Windows_UI_Xaml_Media_ImageBrushTests_ImageBrush_Formats
    • Brushes_UITests_Windows_UI_Xaml_Media_ImageBrushTests_ImageBrush_Stretch_UITests_Windows_UI_Xaml_Media_ImageBrushTests_ImageBrush_Stretch
    • ComboBox_UITests_Shared_Windows_UI_Xaml_Controls_ComboBox_ComboBox_DropDownPlacement_UITests_Shared_Windows_UI_Xaml_Controls_ComboBox_ComboBox_DropDownPlacement
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Smaller_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Smaller
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Wider_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Wider
    • LoopingSelector_UITests_Windows_UI_Xaml_Controls_LoopingSelectorTests_LoopingSelector_Items_UITests_Windows_UI_Xaml_Controls_LoopingSelectorTests_LoopingSelector_Items
    • Progress_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
  • skia-gtk-screenshots: 15 changed over 1114

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ListView-ListViewSelectedItems.png
    • MUX-TabViewPage.png
    • MUX-WinUIProgressRingPage.png
    • MUX-WinUIProgressRing_CustomSources.png
    • MediaPlayerElement-MediaPlayerElement_Stretch_Fill.png
    • Pickers-CalendarView_Theming.png
    • TextBlock-TextBoxSizeChanging.png
    • Progress-ProgressRingHeightTest.png
    • Progress-WindowsProgressRing_GH1220.png
    • Progress-WinUIProgressRingPage.png
    • Progress-WinUIProgressRing_CustomSources.png
    • Progress-WinUIProgressRing_Features.png
    • TextBlock-TextBlockMultilineInStarStackPanel.png
    • WinUI-PipsPagerExamples.png
    • PipsPager-PipsPagerExamples.png
  • skia-wpf-screenshots: 13 changed over 1114

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Image-UniformToFill100x100.png
    • Pickers-CalendarView_Theming.png
    • MUX-WinUIProgressRingPage.png
    • MUX-WinUIProgressRing_CustomSources.png
    • PipsPager-PipsPagerExamples.png
    • MUX-TabViewPage.png
    • Progress-ProgressRingHeightTest.png
    • Progress-WindowsProgressRing_GH1220.png
    • Progress-WinUIProgressRing_Features.png
    • Transform-TransformToVisual_Translate2d.png
    • WinUI-PipsPagerExamples.png
    • Progress-WinUIProgressRingPage.png
    • Progress-WinUIProgressRing_CustomSources.png
  • wasm: 32 changed over 1038

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Samples.Windows_UI_Xaml_Controls.NavigationViewTests.NavigationView_BasicNavigation
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Windows_UI_Xaml_Shapes.Offscreen_Shapes
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_3gp_Extension
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewLargeHeader
    • UITests.Uno_Web.Http.CookieManagerTests
    • initial_state
    • UITests.Microsoft_UI_Xaml_Controls.ProgressRing.WinUIProgressRingPage
    • MUXControlsTestApp.NavigationViewBlankPage1
    • MUXControlsTestApp.PersonPicturePage
    • UITests.Microsoft_UI_Xaml_Controls.NavigationViewTests.NavigationViewBasicPage
    • UITests.Windows_UI_Xaml_Controls.ProgressRing.WindowsProgressRing_GH1220
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Windows_UI_ViewManagement.ApplicationViewSizing
    • UITests.Microsoft_UI_Xaml_Controls.ProgressRing.ProgressRingHeightTest
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Avi_Extension
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Flv_Extension
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Mkv_Extension
  • wasm-automated-net7.0-UWP-Benchmarks: 0 changed over 1

  • wasm-automated-net7.0-UWP-Default: 40 changed over 1921

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Brushes_Uno_UI_Samples_Samples_Shared_Content_UITests_ImageBrushInList_Uno_UI_Samples_Samples_Shared_Content_UITests_ImageBrushInList
    • LoopingSelector_UITests_Windows_UI_Xaml_Controls_LoopingSelectorTests_LoopingSelector_Short_UITests_Windows_UI_Xaml_Controls_LoopingSelectorTests_LoopingSelector_Short
    • ListView_ListViewSelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • ListView_SelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • DatePicker_Flyout_DatePicker_-_Flyout
    • MediaPlayerElement_Using_avi_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Avi_Extension
    • MediaPlayerElement_Using_flv_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Flv_Extension
    • MediaPlayerElement_Using_mkv_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Mkv_Extension
    • MediaPlayerElement_Using_mov_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Mov_Extension
    • MediaPlayerElement_Using_mp3_Audio_only_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Mp3_Extension
    • MediaPlayerElement_Using_ogg_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Ogg_Extension
    • MinMaxTest_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
    • MediaPlayerElement_MediaPlayerElement_Stretch_Fill_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Stretch_Fill
    • MediaPlayerElement_Mini_player_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Minimal
    • MediaPlayerElement_Sources_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Sources
    • MediaPlayerElement_Using_3gp_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_3gp_Extension
    • ColorPicker_WinUIColorPickerPage_UITests_Shared_Microsoft_UI_Xaml_Controls_ColorPickerTests_WinUIColorPickerPage
    • Default_SamplesApp_Wasm_Windows_UI_Xaml_Controls_ListView_ListView_IsSelected_SamplesApp_Wasm_Windows_UI_Xaml_Controls_ListView_ListView_IsSelected
    • Progress_UITests_Microsoft_UI_Xaml_Controls_ProgressRing_ProgressRingHeightTest_UITests_Microsoft_UI_Xaml_Controls_ProgressRing_ProgressRingHeightTest
    • Progress_UITests_Microsoft_UI_Xaml_Controls_ProgressRing_WinUIProgressRingPage_UITests_Microsoft_UI_Xaml_Controls_ProgressRing_WinUIProgressRingPage
  • wasm-automated-net7.0-UWP-RuntimeTests: 0 changed over 1

  • wasm-automated-net7.0-WinUI-RuntimeTests: 0 changed over 1

@MartinZikmund MartinZikmund merged commit 7dd4964 into master Jul 27, 2023
@MartinZikmund MartinZikmund deleted the dev/mazi/style-setters-theming branch July 27, 2023 03:12
@MartinZikmund
Copy link
Member Author

@Mergifyio backport legacy/4x

@mergify
Copy link
Contributor

mergify bot commented Jul 27, 2023

backport legacy/4x

✅ Backports have been created

MartinZikmund added a commit that referenced this pull request Jul 27, 2023
fix: `ThemeResource` bindings are not scope-updated on `Style` switch (backport #13016)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Overrides][PipsPager][Fluent] Overrides on the style of PipsPager do not work well
5 participants