We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataContext={Binding} on a UserControl inside a DataTemplate is broken in 11.2.0
DataContext={Binding}
UserControl
DataTemplate
11.2.0
11.1.4
MainWindow.axaml
... <ContentControl Content="{Binding Book}"> <ContentControl.DataTemplates> <DataTemplate DataType="m:Book"> <StackPanel> <TextBlock Background="Red" Text="{Binding}" /> <!-- <v:UserControl1 Background="Yellow" /> will be OK --> <!-- however the following will be invisible --> <v:UserControl1 Background="Yellow" DataContext="{Binding}" /> <ContentControl Background="Green" Content="{Binding}"> <ContentControl.DataTemplates> <DataTemplate x:DataType="m:Book"> <StackPanel> <TextBlock Text="{Binding}" /> </StackPanel> </DataTemplate> </ContentControl.DataTemplates> </ContentControl> </StackPanel> </DataTemplate> </ContentControl.DataTemplates> </ContentControl> ...
UserControl1.axaml
... <ContentControl Content="{Binding}"> <ContentControl.DataTemplates> <DataTemplate x:DataType="m:Book"> <StackPanel> <TextBlock Text="{Binding}" /> </StackPanel> </DataTemplate> </ContentControl.DataTemplates> </ContentControl> ...
MainWindowViewModel.cs
public partial class MainWindowViewModel : ViewModelBase { public Book Book { get; } = new(); }
Book.cs
public record Book(string Name = "Avalonia", int Price = 4000);
Binding works properly as in 11.1.4
Windows
May be related to #16242
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe the bug
DataContext={Binding}
on aUserControl
inside aDataTemplate
is broken in 11.2.011.2.0
11.1.4
To Reproduce
MainWindow.axaml
UserControl1.axaml
MainWindowViewModel.cs
Book.cs
Expected behavior
Binding works properly as in 11.1.4
Avalonia version
11.2.0
OS
Windows
Additional context
May be related to #16242
The text was updated successfully, but these errors were encountered: