Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -772,4 +772,109 @@ public async Task TestRelativeSourceShortSyntax()

await test.RunAsync();
}

[TestMethod]
public async Task When_Static_XBind_Property_In_DataTemplate_Without_DataType()
{
var xamlFiles = new[]
{
new XamlFile("MainPage.xaml", """
<Page x:Class="TestRepro.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestRepro">
<ContentControl x:Name="root">
<ContentControl.ContentTemplate>
<DataTemplate>
<TextBlock Text="{x:Bind local:StaticData.StaticProperty}" />
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
</Page>
"""),
};
var test = new Verify.Test(xamlFiles)
{
TestState =
{
Sources =
{
"""
using Microsoft.UI.Xaml.Controls;

namespace TestRepro
{
public static class StaticData
{
public static string StaticProperty => "Static Value";
}

public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
}
}
"""
}
}
}.AddGeneratedSources();

await test.RunAsync();
}

[TestMethod]
public async Task When_Static_XBind_Event_In_DataTemplate_Without_DataType()
{
var xamlFiles = new[]
{
new XamlFile("MainPage.xaml", """
<Page x:Class="TestRepro.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestRepro">
<ContentControl x:Name="root">
<ContentControl.ContentTemplate>
<DataTemplate>
<Button Click="{x:Bind local:StaticHandler.OnClick}" />
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
</Page>
"""),
};
var test = new Verify.Test(xamlFiles)
{
TestState =
{
Sources =
{
"""
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace TestRepro
{
public static class StaticHandler
{
public static void OnClick(object sender, RoutedEventArgs e) { }
}

public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
}
}
"""
}
}
}.AddGeneratedSources();

await test.RunAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
ο»Ώ// <autogenerated />
namespace MyProject
{
/// <summary>
/// Contains all the static resources defined for the application
/// </summary>
/// <exclude />
[global::System.CodeDom.Compiler.GeneratedCode("Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGeneration", "255.255")]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class GlobalStaticResources
{
static bool _initialized;
private static bool _stylesRegistered;
private static bool _dictionariesRegistered;
internal static global::Uno.UI.Xaml.XamlParseContext __ParseContext_ { get; } = new global::Uno.UI.Xaml.XamlParseContext()
{
AssemblyName = "TestProject",
}
;

static GlobalStaticResources()
{
Initialize();
}
public static void Initialize()
{
if (!_initialized)
{
_initialized = true;
global::Uno.UI.GlobalStaticResources.Initialize();
global::Uno.UI.GlobalStaticResources.RegisterDefaultStyles();
global::Uno.UI.GlobalStaticResources.RegisterResourceDictionariesBySource();
}
}
public static void RegisterDefaultStyles()
{
if(!_stylesRegistered)
{
_stylesRegistered = true;
RegisterDefaultStyles_MainPage_d6cd66944958ced0c513e0a04797b51d();
}
}
// Register ResourceDictionaries using ms-appx:/// syntax, this is called for external resources
public static void RegisterResourceDictionariesBySource()
{
if(!_dictionariesRegistered)
{
_dictionariesRegistered = true;
}
}
// Register ResourceDictionaries using ms-resource:/// syntax, this is called for local resources
internal static void RegisterResourceDictionariesBySourceLocal()
{
}
static partial void RegisterDefaultStyles_MainPage_d6cd66944958ced0c513e0a04797b51d();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ο»Ώ// <auto-generated />
[assembly: global::System.Reflection.AssemblyMetadata("UnoHasLocalizationResources", "False")]
Loading
Loading