Giter VIP home page Giter VIP logo

Comments (14)

timunie avatar timunie commented on August 29, 2024

Interesting. If you disable CompiledBindings for a test, does it disappear?

from avalonia.

busitech avatar busitech commented on August 29, 2024

After adding this to my project file, the result is the same.

<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>

MaskedTextBox has not changed very much, so it is doing what it has always done, which is to refresh the Text property in the OnTextInput OnKeyDown and OnPropertyChanged events. If I comment out line 443 in MaskedTextBox.cs, the problem goes away, but of course then the control displays nothing:

SetCurrentValue(TextProperty, provider.ToDisplayString());

The Binding System went though a major refactor (#13970), so I assume that the issue was introduced there. The initial Text value is being set to null, the OnPropertyChanged event fires, causing a refresh to the Text property (again), and the cycle seems to repeat.

The docs say the SetCurrentValue method is supposed to be used for programmatically setting a bound property, so it makes sense that is the method called during the events.

from avalonia.

busitech avatar busitech commented on August 29, 2024

This issue caught my eye, but it did not help to test without the changes. I thought I'd mention it here anyway.

Make bindings react to PropertyChanged even if property hasn't changed #16150

from avalonia.

timunie avatar timunie commented on August 29, 2024

Thanks for testing. I also end up in an infinite cycle with another 3rd party control and can't wrap my head around. So if it was compiled bindings extension, that would have been a good entry point. I'm also certain it has to do with the bindings refractor somehow.

/cc @grokys will try to see if I can mange to get this into Sandbox to narrow it down as this is also bugging me ^^

from avalonia.

timunie avatar timunie commented on August 29, 2024

@busitech I can't reproduce this with a simple sample :-( Can you provide a minimal sample for me to test?

My ViewModel:

public partial class MainViewModel: ObservableObject
{
    [ObservableProperty] private string? _name;
}

My MainView:

<MaskedTextBox Text="{Binding Name}" Mask="???" />

from avalonia.

busitech avatar busitech commented on August 29, 2024

Yes, here is my test project.

MaskedTextBoxTest.zip

from avalonia.

busitech avatar busitech commented on August 29, 2024

Hello @timunie, were you able to reproduce with my sample?

from avalonia.

busitech avatar busitech commented on August 29, 2024

Another side effect of the binding system changes is that the source property of the Binding on the Text property of the MaskedTextBox is being set to the masked value, even before any user input has been made in the control.

At 11.0.13, no changes would be made to the source property until user input occurs. This would be the correct behavior.

from avalonia.

busitech avatar busitech commented on August 29, 2024

One input necessary to reproduce this issue is to bind the Text property on the MaskedTextBox to an initial value that does not conform to the mask (including null or empty string).

from avalonia.

timunie avatar timunie commented on August 29, 2024

Hello @timunie, were you able to reproduce with my sample?

Guess what? I was able to reproduce it with your sample attached. I added the relevant parts to Sandbox, and the issue was gone. Can't wrap my head around it yet 🤷

from avalonia.

busitech avatar busitech commented on August 29, 2024

I am reproducing with the nightly build 11.2.999-cibuild0051406-alpha, and with my sample directly inside the Avalonia project, using the latest commit.

I produced a patch today that takes care of the writing back of the value during the initial subscription, and that took care of the cycle.

from avalonia.

busitech avatar busitech commented on August 29, 2024

This is a very simple approach to preventing the stack overflow, by preventing the write-back of the value to the source during publish.

prevent_stack_overflow.patch

from avalonia.

timunie avatar timunie commented on August 29, 2024

👍 could you make a PR of that patch?

  • Helps to run unit tests
  • easier for the team to feedback and double-check

from avalonia.

busitech avatar busitech commented on August 29, 2024

Today I made a new patch I am more pleased with. It will be the basis of my PR.

from avalonia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.