question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MVVM fails - Compiled Bindings are now the default? A11P6

See original GitHub issue

Describe the bug My application employs MVVM and data bindings. Previously, under 10.18, following axaml View snippet worked fine:

    <views:CodeTextBox Grid.Row="0"
        Name="PlainTextBox"
        Classes="mono"
        IsReadOnly="True"
        IsVisible="{Binding IsPlainTextViewable}">
    </views:CodeTextBox>

Note the IsVisible="{Binding IsPlainTextViewable}"> .

Now, under 11P6, it fails to compile with the error:

... PreviewPane.axaml(17,13,17,13): Avalonia error AVLN:0004: Cannot parse a compiled binding without an explicit x:DataType directive to give a starting data type for bindings.

However, if I goto the root and add the line:

x:CompileBindings="False"

to the following:

<UserControl xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:views="clr-namespace:AvantGarde.Views"
    mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="300"

    x:CompileBindings="False"

    x:Class="AvantGarde.Views.PreviewPane">

Then everything works fine.

THIS SUGGESTS THAT COMPILED BINDINGS IS NOW THE DEFAULT?

But the documentation states: “Compiled bindings are not enabled by default.”

See: https://docs.avaloniaui.net/docs/data-binding/compiledbindings

Is this the case? Has it changed? I can find no reference to it in the list of version 11 breaking changes?

Or could I be missing something here? Is there some other global “compiled bindings setting”?

Or is this a bug?

Expected behavior Compiled bindings are not default.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Fedora 37
  • Version 11 Preview 6

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 6 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
rabbitismcommented, Mar 23, 2023

IRCC you can disable it in csproj with <AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>

1reaction
timuniecommented, Mar 23, 2023

Cast it like in c#

IsVisible="{Binding $parent.((vm:MainViewModel)DataContext).IsXamlViewable}"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Compiled bindings - .NET MAUI
Compiled bindings require the use of XAML compilation, which is enabled by default in .NET MAUI. If you've disabled XAML compilation, ...
Read more >
Relative Bindings Fail with CompileBindings Enabled ...
Describe the bug I'm experiencing an issue with Avalonia 11.0.0-rc1.1 where relative bindings fail to compile when CompileBindings is ...
Read more >
MAUI BindingContext does not work when set to a Binding
I found the answer myself in the Compiled bindings documentation. It turns out the x:DataType="vm:MainViewModel" is the problem, ...
Read more >
Command binding on Button not working out of the box?
You're just not seeing them and by default they happen at runtime. Use compiled bindings to get compile-time checking: https://learn.microsoft.
Read more >
Better Performance with Compiled Bindings - .NET MAUI 101
With one simple XAML attribute in .NET MAUI you can improve your apps performance _and_ get IntelliSense for your data binding.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found