-
Notifications
You must be signed in to change notification settings - Fork 743
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 #12725 from unoplatform/dev/xygu/20230614/robertl-…
…vs-converter-debugging Converters on VisualStates won't be triggered more than once
- Loading branch information
Showing
9 changed files
with
320 additions
and
27 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
....RuntimeTests/Tests/Windows_UI_Xaml/Controls/When_Refresh_Setter_BindingOnInvocation.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,46 @@ | ||
<UserControl x:Class="Uno.UI.RuntimeTests.When_Refresh_Setter_BindingOnInvocation" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:local="using:Uno.UI.RuntimeTests" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<UserControl.Resources> | ||
<local:When_Refresh_Setter_BindingOnInvocation_Converter x:Key="testConverter" /> | ||
</UserControl.Resources> | ||
|
||
<ContentControl x:Name="root" | ||
x:FieldModifier="public"> | ||
<ContentControl.Template> | ||
<ControlTemplate TargetType="ContentControl"> | ||
<Border> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal"> | ||
<VisualState.Setters> | ||
<Setter Target="ContentElement_CompositeTransform.TranslateY" | ||
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource testConverter}, TargetNullValue=-1, FallbackValue=-2}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
<VisualState x:Name="Focused"> | ||
<VisualState.Setters> | ||
<Setter Target="ContentElement_CompositeTransform.TranslateY" | ||
Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource testConverter}, TargetNullValue=-3, FallbackValue=-4}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
|
||
<Border x:Name="ContentElement"> | ||
<ContentPresenter /> | ||
<Border.RenderTransform> | ||
<CompositeTransform x:Name="ContentElement_CompositeTransform" /> | ||
</Border.RenderTransform> | ||
</Border> | ||
</Border> | ||
</ControlTemplate> | ||
|
||
</ContentControl.Template> | ||
</ContentControl> | ||
</UserControl> |
47 changes: 47 additions & 0 deletions
47
...ntimeTests/Tests/Windows_UI_Xaml/Controls/When_Refresh_Setter_BindingOnInvocation.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,47 @@ | ||
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 User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||
|
||
namespace Uno.UI.RuntimeTests | ||
{ | ||
public sealed partial class When_Refresh_Setter_BindingOnInvocation : UserControl | ||
{ | ||
public When_Refresh_Setter_BindingOnInvocation() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
|
||
public class When_Refresh_Setter_BindingOnInvocation_Converter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, string language) | ||
{ | ||
var ctrl = value as ContentControl; | ||
|
||
if (ctrl is not null) | ||
{ | ||
return ctrl.Tag ?? -10; | ||
} | ||
|
||
return -10; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, string language) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...s/Tests/Windows_UI_Xaml/Controls/When_Refresh_Setter_BindingOnInvocation_ElementName.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,49 @@ | ||
<UserControl x:Class="Uno.UI.RuntimeTests.When_Refresh_Setter_BindingOnInvocation_ElementName" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:local="using:Uno.UI.RuntimeTests" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<UserControl.Resources> | ||
<local:When_Refresh_Setter_BindingOnInvocation_ElementName_Converter x:Key="testConverter" /> | ||
</UserControl.Resources> | ||
|
||
<StackPanel x:Name="sp01" | ||
x:FieldModifier="public"> | ||
<ContentControl x:Name="root" | ||
x:FieldModifier="public"> | ||
<ContentControl.Template> | ||
<ControlTemplate TargetType="ContentControl"> | ||
<Border> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal"> | ||
<VisualState.Setters> | ||
<Setter Target="ContentElement_CompositeTransform.TranslateY" | ||
Value="{Binding ElementName=sp01, Converter={StaticResource testConverter}, TargetNullValue=-1, FallbackValue=-2}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
<VisualState x:Name="Focused"> | ||
<VisualState.Setters> | ||
<Setter Target="ContentElement_CompositeTransform.TranslateY" | ||
Value="{Binding ElementName=sp01, Converter={StaticResource testConverter}, TargetNullValue=-3, FallbackValue=-4}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
|
||
<Border x:Name="ContentElement"> | ||
<ContentPresenter /> | ||
<Border.RenderTransform> | ||
<CompositeTransform x:Name="ContentElement_CompositeTransform" /> | ||
</Border.RenderTransform> | ||
</Border> | ||
</Border> | ||
</ControlTemplate> | ||
|
||
</ContentControl.Template> | ||
</ContentControl> | ||
</StackPanel> | ||
</UserControl> |
47 changes: 47 additions & 0 deletions
47
...ests/Windows_UI_Xaml/Controls/When_Refresh_Setter_BindingOnInvocation_ElementName.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,47 @@ | ||
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 User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||
|
||
namespace Uno.UI.RuntimeTests | ||
{ | ||
public sealed partial class When_Refresh_Setter_BindingOnInvocation_ElementName : UserControl | ||
{ | ||
public When_Refresh_Setter_BindingOnInvocation_ElementName() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
|
||
public class When_Refresh_Setter_BindingOnInvocation_ElementName_Converter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, string language) | ||
{ | ||
var ctrl = value as FrameworkElement; | ||
|
||
if (ctrl is not null) | ||
{ | ||
return ctrl.Tag ?? -10; | ||
} | ||
|
||
return -10; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, string language) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} |
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.