Open
Description
Describe the bug
x bind function does not work within datatemplate
xaml
<Page
x:Class="WinUI3DesktopMVVM.Views.LayoutSandBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUI3DesktopMVVM.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:staticStuff ="using:WinUI3DesktopMVVM"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<DataTemplate x:Key="myTemplate">
<TextBlock Text="{x:Bind staticStuff:StaticTestClass.GetString()}"/>
</DataTemplate>
</Page.Resources>
<StackPanel Background="DarkCyan">
<ContentControl ContentTemplate="{StaticResource myTemplate}"/><!--does not work-->
<ContentControl Content="{x:Bind staticStuff:StaticTestClass.GetString()}"/> <!--works fine-->
</StackPanel>
</Page>
code
namespace WinUI3DesktopMVVM
{
public class StaticTestClass
{
public static string StaticSTring { get; set; } = "TESTing stirng";
public static string GetString()
{
return "TEST_string";
}
}
}
Steps to reproduce the bug
just copy paste this code in winui3 app
Expected behavior
expected string to be printed twice but it's printed only once
Screenshots
NuGet package version
WinUI 3 - Windows App SDK 1.1.5
Windows app type
- UWP
- Win32
Device form factor
Desktop
Windows version
Windows 11 (21H2): Build 22000
Additional context
No response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment