dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.85k stars 1.68k forks source link

Adding value dynamically using parameters to the InputTextarea in the OnBindingContextChanged after some delay, the value not updated properly. #22486

Open VinithaJeyakumar opened 1 month ago

VinithaJeyakumar commented 1 month ago

Description

Steps to Reproduce

  1. Create a InputTextarea in the Razor file with bind-value variable as parameter.
  2. pass value to the variable using parameter in the OnBindingContextChanged function in Xaml.cs file with some delay.
  3. Now run the sample and check the value.

Code snippet: -----Razor page----

<InputTextArea @bind-Value ="@TextContent">

@code {

[Parameter]
public string TextContent{ get; set; }

-----Xaml.cs--------

protected override async void OnBindingContextChanged()
{
    base.OnBindingContextChanged();
    //await viewModel.Init();

    new Task(async () =>
    {
        await Task.Delay(2000);
        //viewModel.College.Details = @"<h1> College Information</h1>";
        var details = "From OnBindingContextChanged";

        rootComponent.Parameters =
        new Dictionary<string, object>
        {
            { "TextContent",  details}
        };
    }).Start();

}

Link to public reproduction project repository

No response

Version with bug

9.0.0-preview.3.10457

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

manjunath-vadigeri commented 1 month ago

I have attached a sample project where I can reproduce the issue - CIllustrationPage.xaml has a BlazorWebView whose root component in CIllustration.razor CIllustration.razor has a SfRichTextEditor whose content property should be dynamically set

In CIllustrationPage.xaml.cs constructor, if I set the parameters => they appear coorectly in RichTextEditor But my content is not yet available at this point.

So, I tried to set the parameters in OnBindingContextChanged method where my data is available. [In the app, I have simulated a delay to represent real data-fetch scenario]

This newly set parameters are not notified to the RichTextEditor [Uploading ParameterIssue.zip…]()

kevinxufei commented 1 month ago

Hi, @manjunath-vadigeri, thank you for providing the repo, but the link of this sample project seems to be incorrect, please upload it again.

manjunath-vadigeri commented 1 month ago

Hello @kevinxufei , I have shared the sample project as a public repo here - https://github.com/manjunath-vadigeri/ParameterIssue

kevinxufei commented 1 month ago

Verified this issue with Visual Studio 17.11 Preview 1 (9.0.0-preview.2.10293/9.0.0-preview.4.10690) + .Net9SDK 9.0.100-preview.4.24267.66. Can repro it on Windows platform.

manjunath-vadigeri commented 1 month ago

While the MAUI team further checks the issue, Is there any work around to overcome this issue?