-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Don't generate invalid code when x:Load and StaticResource marku…
…p is used
- Loading branch information
1 parent
e0b62e5
commit 70f756b
Showing
5 changed files
with
158 additions
and
20 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
19 changes: 19 additions & 0 deletions
19
src/Uno.UI.Tests/Windows_UI_Xaml/Controls/When_xLoad_DataTemplate_In_ResDict.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,19 @@ | ||
<UserControl | ||
x:Class="Uno.UI.Tests.Windows_UI_Xaml.Controls.When_xLoad_DataTemplate_In_ResDict" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.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"> | ||
<UserControl.Resources> | ||
<ResourceDictionary Source="When_xLoad_DataTemplate_In_ResDict_Global.xaml"/> | ||
</UserControl.Resources> | ||
|
||
<Grid> | ||
<Grid.Resources> | ||
<SolidColorBrush x:Key="MyBrush" Color="Red"/> | ||
</Grid.Resources> | ||
<ContentControl ContentTemplate="{StaticResource MyContainerTemplate}" /> | ||
</Grid> | ||
</UserControl> |
55 changes: 55 additions & 0 deletions
55
src/Uno.UI.Tests/Windows_UI_Xaml/Controls/When_xLoad_DataTemplate_In_ResDict.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,55 @@ | ||
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.Tests.Windows_UI_Xaml.Controls | ||
{ | ||
public sealed partial class When_xLoad_DataTemplate_In_ResDict : UserControl | ||
{ | ||
public When_xLoad_DataTemplate_In_ResDict() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
public bool MyVisibility | ||
{ | ||
get { return (bool)GetValue(MyVisibilityProperty); } | ||
set { SetValue(MyVisibilityProperty, value); } | ||
} | ||
|
||
// Using a DependencyProperty as the backing store for MyVisibility. This enables animation, styling, binding, etc... | ||
public static readonly DependencyProperty MyVisibilityProperty = | ||
DependencyProperty.Register("MyVisibility", typeof(bool), typeof(When_xLoad_DataTemplate_In_ResDict), new PropertyMetadata(false)); | ||
} | ||
|
||
public class When_xLoad_DataTemplate_In_ResDict_Model : System.ComponentModel.INotifyPropertyChanged | ||
{ | ||
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; | ||
|
||
private bool visible; | ||
|
||
public bool Visible | ||
{ | ||
get { return visible; } | ||
set | ||
{ | ||
visible = value; | ||
PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(nameof(Visible))); | ||
} | ||
} | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Uno.UI.Tests/Windows_UI_Xaml/Controls/When_xLoad_DataTemplate_In_ResDict_Global.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,24 @@ | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:xamarin="http://uno.ui/xamarin" | ||
xmlns:local="using:Uno.UI.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 xamarin"> | ||
|
||
<DataTemplate x:Key="MyContainerTemplate" x:DataType="local:When_xLoad_DataTemplate_In_ResDict_Model"> | ||
<StackPanel> | ||
<TextBlock x:Name="tb01" | ||
Text="Please fill in the empty form fields." | ||
x:Load="{x:Bind Visible, Mode=OneWay}" | ||
Margin="15" | ||
Foreground="{StaticResource MyBrush}" /> | ||
<TextBlock x:Name="tb02" | ||
Text="Please fill in the empty form fields." | ||
Margin="15" | ||
Foreground="{StaticResource MyBrush}" /> | ||
</StackPanel> | ||
</DataTemplate> | ||
|
||
</ResourceDictionary> |
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