C
C#2y ago
friedice

❔ Data-binding multiple components Blazor

So let's say I have 3 components. Component C is a child of component B, and component B is a child of component A. Is it possible 2-way bind Component C and component A so that when a parameter value of Component C is updated, Component A's value will also get updated?
2 Replies
friedice
friediceOP2y ago
I tried cascading value, but Component A's value wasn't being updated until I manually call StateHasChanged()
\\Component C
<Component D
@bind-SelectedItems=SelectedItems/>

@code
{
[CascadingParameter]
public List<stuff> Selecteditems {get;set;}
}
\\Component B
<Component C />

\\Component A
<CascadingValue Name=SelectedItems Value=Data.SelectedItems>
<Component B/>
</CascadingValue>

@code
{
public class Data
{
public List<stuff> SelectedItems {get;set;}
}
}
\\Component C
<Component D
@bind-SelectedItems=SelectedItems/>

@code
{
[CascadingParameter]
public List<stuff> Selecteditems {get;set;}
}
\\Component B
<Component C />

\\Component A
<CascadingValue Name=SelectedItems Value=Data.SelectedItems>
<Component B/>
</CascadingValue>

@code
{
public class Data
{
public List<stuff> SelectedItems {get;set;}
}
}
something like this is what i have do I have to post on stackoverflow when
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server