-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3abb0a5
commit 7ba11db
Showing
2 changed files
with
85 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests" | ||
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui13585"> | ||
<ContentPage.Resources> | ||
<Color x:Key="MyPrimaryColor">Green</Color> | ||
<Color x:Key="MyReadOnlyColor">Purple</Color> | ||
|
||
<Style TargetType="Button" x:Key="MyStaticResourceButtonStyle"> | ||
<Setter Property="BackgroundColor" Value="{StaticResource MyPrimaryColor}" /> | ||
<Style.Triggers> | ||
<Trigger TargetType="Button" Property="IsEnabled" Value="False" > | ||
<Setter Property="BackgroundColor" Value="{StaticResource MyReadOnlyColor}" /> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
|
||
<Style TargetType="Button" x:Key="MyDynamicResourceButtonStyle"> | ||
<Setter Property="BackgroundColor" Value="{DynamicResource MyPrimaryColor}" /> | ||
<Style.Triggers> | ||
<Trigger TargetType="Button" Property="IsEnabled" Value="False" > | ||
<Setter Property="BackgroundColor" Value="{DynamicResource MyReadOnlyColor}" /> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
</ContentPage.Resources> | ||
<StackLayout> | ||
<Button x:Name="styleTriggerWithStaticResources" Style="{StaticResource MyStaticResourceButtonStyle}" /> | ||
<Button x:Name="styleTriggerWithDynamicResources" Style="{StaticResource MyDynamicResourceButtonStyle}" /> | ||
</StackLayout> | ||
</ContentPage> |
51 changes: 51 additions & 0 deletions
51
src/Controls/tests/Xaml.UnitTests/Issues/Maui13585.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,51 @@ | ||
using System; | ||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.ApplicationModel; | ||
using Microsoft.Maui.Controls.Core.UnitTests; | ||
using Microsoft.Maui.Devices; | ||
using NUnit.Framework; | ||
|
||
|
||
namespace Microsoft.Maui.Controls.Xaml.UnitTests | ||
{ | ||
|
||
|
||
public partial class Maui13585 : ContentPage | ||
{ | ||
public Maui13585() => InitializeComponent(); | ||
public Maui13585(bool useCompiledXaml) | ||
{ | ||
//this stub will be replaced at compile time | ||
} | ||
|
||
|
||
|
||
[TestFixture] | ||
class Tests | ||
{ | ||
[SetUp] public void Setup() => AppInfo.SetCurrent(new MockAppInfo()); | ||
[TearDown] public void TearDown() => AppInfo.SetCurrent(null); | ||
|
||
[Test] | ||
public void TriggerWithDynamicResource([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
var page = new Maui13585(useCompiledXaml); | ||
Assert.That(page.styleTriggerWithStaticResources.BackgroundColor, Is.EqualTo(Colors.Green)); | ||
Assert.That(page.styleTriggerWithDynamicResources.BackgroundColor, Is.EqualTo(Colors.Green)); | ||
|
||
page.styleTriggerWithStaticResources.IsEnabled = false; | ||
page.styleTriggerWithDynamicResources.IsEnabled = false; | ||
|
||
Assert.That(page.styleTriggerWithStaticResources.BackgroundColor, Is.EqualTo(Colors.Purple)); | ||
Assert.That(page.styleTriggerWithDynamicResources.BackgroundColor, Is.EqualTo(Colors.Purple)); | ||
|
||
page.styleTriggerWithStaticResources.IsEnabled = true; | ||
page.styleTriggerWithDynamicResources.IsEnabled = true; | ||
|
||
Assert.That(page.styleTriggerWithStaticResources.BackgroundColor, Is.EqualTo(Colors.Green)); | ||
Assert.That(page.styleTriggerWithDynamicResources.BackgroundColor, Is.EqualTo(Colors.Green)); | ||
|
||
} | ||
} | ||
} | ||
} |