-
Notifications
You must be signed in to change notification settings - Fork 803
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When using a Binding with ElementName from within a TreeViewItem in a DataTemplate, the binding is not resolved and no binding errors are reported.
Steps to reproduce the bug
<Window
x:Class="App10.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App10"
x:Name="window">
<TreeView ItemsSource="{x:Bind ViewModels}">
<TreeView.ItemTemplate>
<DataTemplate x:DataType="local:Entity">
<TreeViewItem ItemsSource="{x:Bind Children}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{x:Bind Name}" />
<TextBlock Text="{Binding StuffProcessor.StuffTitle, ElementName=window}" />
</StackPanel>
</TreeViewItem>
</DataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Window>using Microsoft.UI.Xaml;
using System.Collections.Generic;
namespace App10;
public sealed partial class MainWindow : Window
{
public MainWindow() =>
InitializeComponent();
public List<Entity> ViewModels { get; } =
[
new("Parent 1")
{
Children=
[
new("Child 1.1"),
new("Child 1.2"),
new("Child 1.3"),
]
},
new("Parent 2")
{
Children=
[
new("Child 2.1"),
new("Child 2.2"),
new("Child 2.3"),
]
},
];
public string Annotation => "Annotation";
}
public class Entity(string name)
{
public string Name { get; } = name;
public List<Entity> Children { get; set; } = [];
}Actual behavior
Expected behavior
Annotation property should be accessed and materialized.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.7.0: 1.7.250310001
Windows version
Windows 11 (22H2): Build 22621
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working

