Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor - update parameter doesn't work on 2nd nested child

$
0
0

I'm probably doing something wrong, but I don't see what I'm missing.

I have three component files (razor files) which implements each other component like so (pseudo code):

Parent.razor:<Child Value = StartValue       ValueChanged = StartValueChanged       MaxValue = EndValue       MaxValueChanged = EndValueChanged/><Child Value = EndValue       ValueChanged = EndValueChanged       MinValue = StartValue       MinValueChanged = MinValueChanged/>Child.razor:<Base Value = Value      ValueChanged = ValueChanged      MinValue = MinValue      MinValueChanged = MinValueChanged      MaxValue = MaxValue      MaxValueChanged = MaxValueChanged />

Base.razor shows the values. In the Child.razor I do conversions to keep the code more manageable. The Values used in this example are local variables updated by functons and these local variables are then passed through to the base.

Now the problem:When either the start or end values are changed in the Parent.razor, the change only goes one layer deep. It only updates the Child.Razor and doesn't continue to the Base.razor.

I have to manually make a reference to the base and give it an update function before it actually updates.

Otherwise the update only occurs when I do something on screen, like a button press.

I've tried invoking the changed functions and StateHasChanged(), but nothing seems to work.

The solution I'm using now is this:

Child.razor:<Base @Ref=BaseRef          Value = Value          ValueChanged = ValueChanged          MinValue = MinValue          MinValueChanged = MinValueChanged          MaxValue = MaxValue          MaxValueChanged = MaxValueChanged           OnOpenDialog = UpdateMinMax/>@code{  UpdateMinMax(){    BaseRef.UpdateMaxValue(MaxValue);    BaseRef.UpdateMinValue(MinValue);  }}

When I use this example I don't need a buttonpress to update the values and it is direct. I know it works, but it doesn't feel the way it should be done. Are there any suggestions?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>