forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request unoplatform#13866 from unoplatform/dev/jela/resour…
…ces-alias
- Loading branch information
Showing
19 changed files
with
478 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
"language": "en", | ||
"words": [ | ||
"Avalonia", | ||
"ambiently", | ||
"binlog", | ||
"Blazor", | ||
"blockquotes", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyAlias.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<ResourceDictionary.ThemeDictionaries> | ||
<ResourceDictionary x:Key="Light"> | ||
<StaticResource x:Key="MyAliasBrush" ResourceKey="MyBrush" /> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="Default"> | ||
<StaticResource x:Key="MyAliasBrush" ResourceKey="MyBrush" /> | ||
</ResourceDictionary> | ||
</ResourceDictionary.ThemeDictionaries> | ||
|
||
</ResourceDictionary> |
12 changes: 12 additions & 0 deletions
12
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyBrush.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<ResourceDictionary.ThemeDictionaries> | ||
<ResourceDictionary x:Key="Light"> | ||
<SolidColorBrush x:Key="MyBrush" Color="{ThemeResource MyColor}" /> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="Default"> | ||
<SolidColorBrush x:Key="MyBrush" Color="{ThemeResource MyColor}" /> | ||
</ResourceDictionary> | ||
</ResourceDictionary.ThemeDictionaries> | ||
</ResourceDictionary> |
12 changes: 12 additions & 0 deletions
12
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyButton.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<Style x:Key="MyButtonStyle" TargetType="Button"> | ||
<Setter Property="Background" Value="{ThemeResource MyBrush}" /> | ||
</Style> | ||
|
||
<Style x:Key="MyButtonWithAliasStyle" TargetType="Button"> | ||
<Setter Property="Background" Value="{ThemeResource MyAliasBrush}" /> | ||
</Style> | ||
</ResourceDictionary> |
13 changes: 13 additions & 0 deletions
13
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyColorGreen.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<ResourceDictionary.ThemeDictionaries> | ||
<ResourceDictionary x:Key="Light"> | ||
<Color x:Key="MyColor">Green</Color> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="Default"> | ||
<Color x:Key="MyColor">DarkGreen</Color> | ||
</ResourceDictionary> | ||
</ResourceDictionary.ThemeDictionaries> | ||
|
||
<x:String x:Key="DummyResource">Dummy</x:String> | ||
</ResourceDictionary> |
14 changes: 14 additions & 0 deletions
14
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyColorRed.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<ResourceDictionary.ThemeDictionaries> | ||
<ResourceDictionary x:Key="Light"> | ||
<Color x:Key="MyColor">Red</Color> | ||
|
||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="Default"> | ||
<Color x:Key="MyColor">DarkRed</Color> | ||
</ResourceDictionary> | ||
</ResourceDictionary.ThemeDictionaries> | ||
|
||
<x:String x:Key="DummyResource">Dummy</x:String> | ||
</ResourceDictionary> |
119 changes: 119 additions & 0 deletions
119
...UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_Theme_Changing_Override.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<Page x:Class="Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls.ThemeResource_Theme_Changing_Override" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
<Page.Resources> | ||
<local:ThemeResource_Theme_Changing_Override_Custom Mode="Red" /> | ||
</Page.Resources> | ||
<StackPanel VerticalAlignment="Center" | ||
HorizontalAlignment="Center" | ||
Spacing="20"> | ||
|
||
<StackPanel Orientation="Horizontal" | ||
Spacing="20" | ||
VerticalAlignment="Center" | ||
HorizontalAlignment="Center"> | ||
<StackPanel HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Spacing="20"> | ||
<TextBlock Text="Page Resources" | ||
HorizontalAlignment="Center" /> | ||
<Button x:Name="button01" | ||
x:FieldModifier="public" | ||
Background="{ThemeResource MyBrush}" | ||
Width="200" | ||
Height="100"> | ||
<TextBlock Text="MyBrush Should Be Red" | ||
TextWrapping="WrapWholeWords" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
</Button> | ||
<Button x:Name="button02" | ||
x:FieldModifier="public" | ||
Background="{ThemeResource MyAliasBrush}" | ||
Width="200" | ||
Height="100"> | ||
<TextBlock Text="MyAliasBrush Should Be Red" | ||
TextWrapping="WrapWholeWords" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
</Button> | ||
<Button x:Name="button03" | ||
x:FieldModifier="public" | ||
Style="{StaticResource MyButtonStyle}" | ||
Width="200" | ||
Height="100"> | ||
<TextBlock Text="MyButtonStyle Should Be Red" | ||
TextWrapping="WrapWholeWords" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
</Button> | ||
<Button x:Name="button04" | ||
x:FieldModifier="public" | ||
Style="{StaticResource MyButtonWithAliasStyle}" | ||
Width="200" | ||
Height="100"> | ||
<TextBlock Text="MyButtonWithAliasStyle Should Be Red" | ||
TextWrapping="WrapWholeWords" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
</Button> | ||
</StackPanel> | ||
<StackPanel Spacing="20"> | ||
<StackPanel.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<local:ThemeResource_Theme_Changing_Override_Custom Mode="Green" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</StackPanel.Resources> | ||
<TextBlock Text="Local Override Resources" | ||
HorizontalAlignment="Center" /> | ||
<Button x:Name="button01_override" | ||
x:FieldModifier="public" | ||
Background="{ThemeResource MyBrush}" | ||
Width="200" | ||
Height="100"> | ||
<TextBlock Text="MyBrush Should Be Green" | ||
TextWrapping="WrapWholeWords" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
</Button> | ||
<Button x:Name="button02_override" | ||
x:FieldModifier="public" | ||
Background="{ThemeResource MyAliasBrush}" | ||
Width="200" | ||
Height="100"> | ||
<TextBlock Text="MyAliasBrush Should Be Green" | ||
TextWrapping="WrapWholeWords" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
</Button> | ||
<Button x:Name="button03_override" | ||
x:FieldModifier="public" | ||
Style="{StaticResource MyButtonStyle}" | ||
Width="200" | ||
Height="100"> | ||
<TextBlock Text="MyButtonStyle Should Be Green" | ||
TextWrapping="WrapWholeWords" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
</Button> | ||
<Button x:Name="button04_override" | ||
x:FieldModifier="public" | ||
Style="{StaticResource MyButtonWithAliasStyle}" | ||
Width="200" | ||
Height="100"> | ||
<TextBlock Text="MyButtonWithAliasStyle Should Be Green" | ||
TextWrapping="WrapWholeWords" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
</Button> | ||
</StackPanel> | ||
</StackPanel> | ||
</StackPanel> | ||
</Page> |
60 changes: 60 additions & 0 deletions
60
...RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_Theme_Changing_Override.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls; | ||
|
||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class ThemeResource_Theme_Changing_Override : Page | ||
{ | ||
public ThemeResource_Theme_Changing_Override() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
|
||
public class ThemeResource_Theme_Changing_Override_Custom : ResourceDictionary | ||
{ | ||
private const string GreenUri = "ms-appx:///Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyColorGreen.xaml"; | ||
private const string RedUri = "ms-appx:///Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyColorRed.xaml"; | ||
private const string BrushUri = "ms-appx:///Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyBrush.xaml"; | ||
private const string AliasUri = "ms-appx:///Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyAlias.xaml"; | ||
private const string ButtonUri = "ms-appx:///Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Controls/ThemeResource_TCO_MyButton.xaml"; | ||
|
||
private string _mode; | ||
|
||
public string Mode | ||
{ | ||
get => _mode; | ||
set | ||
{ | ||
_mode = value; | ||
var colorUri = _mode == "Green" ? GreenUri : RedUri; | ||
|
||
var myBrush = new ResourceDictionary { Source = new Uri(BrushUri) }; | ||
var myAlias = new ResourceDictionary { Source = new Uri(AliasUri) }; | ||
var myButton = new ResourceDictionary { Source = new Uri(ButtonUri) }; | ||
|
||
myBrush.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(colorUri) }); | ||
myAlias.MergedDictionaries.Add(myBrush); | ||
myButton.MergedDictionaries.Add(myAlias); | ||
|
||
MergedDictionaries.Add(myButton); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.