maui icon indicating copy to clipboard operation
maui copied to clipboard

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

Open VinithaJeyakumar opened this issue 1 year ago • 4 comments

Description

  • When we try to bind a value to the InputTextarea in the Razor file using some parameter in the OnBindingContextChanged function after some delay of 2000ms, the dynamically added value is not reflected in the text area.

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"></InputTextArea>

@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

VinithaJeyakumar avatar May 17 '24 12:05 VinithaJeyakumar

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…

manjunath-vadigeri avatar May 21 '24 16:05 manjunath-vadigeri

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

kevinxufei avatar May 22 '24 08:05 kevinxufei

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

manjunath-vadigeri avatar May 22 '24 09:05 manjunath-vadigeri

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.

kevinxufei avatar May 24 '24 02:05 kevinxufei

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

manjunath-vadigeri avatar May 27 '24 06:05 manjunath-vadigeri

Thanks for contacting us. Changing existing root components is not supported. Consider utilizing a shared service to pass information between native and Razor context.

mkArtakMSFT avatar Sep 23 '24 18:09 mkArtakMSFT