@code { public static string parentMessage { get; set; } = "Initial value" /> @code { public static string parentMessage { get; set; } = "Initial value" /> @code { public static string parentMessage { get; set; } = "Initial value"/>

Bind child property from RadzenPanelMenuItem

125 Views Asked by At

I have a parent Item:

<Plugins @bind-ChildMessage="parentMessage"></Plugins> 
@code {
 public static string parentMessage { get; set; } = "Initial value set in Parent";

 private void ChangeValue()
 {
     parentMessage = $"Set in Parent {DateTime.Now}";
 }
}

then I tryied to bind this string into a blazor components like this:

<p>Child Message: <b>@ChildMessage</b></p>
<p>
    <button @onclick="async ()=> await ChangeValue()">Change from Child</button>
</p>

@code {
    [Inject]


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

    [Parameter]
    public EventCallback<string> ChildMessageChanged { get; set; }

    private async Task ChangeValue()
    {
        ChildMessage = $"Set in Child {DateTime.Now}";


        await ChildMessageChanged.InvokeAsync(
            $"Set in Child {DateTime.Now}");
    }
}

And it Works.

But Now, in my parent I use a RadzenPanelMenuItem that dynamically calls child items :

<RadzenPanelMenuItem data-bind:ChildMessage="@parentMessage" Text="Plugins"  Path="" Icon="home" class="rz-panel-menu" />
@code {
 public static string parentMessage { get; set; } = "Initial value set in Parent";

 private void ChangeValue()
 {
     parentMessage = $"Set in Parent {DateTime.Now}";
 }
}

It doesn't work , do you have any idea to call child parameters from a RadzenPanelMenuItem

0

There are 0 best solutions below