Question
How do I find a specific subcomponent?
I have a Blazor server-side app, which simulates a windowing system. This uses the TelerikWindow component. Each child window is a separate component, inheriting from a WindowBase
component and containing the code for the specific window.
The component that manages the windows has a collection of WindowParameter
objects, which for simplicity can be considered as...
public ObservableCollection<WindowParameters> Windows { get; set; } = [];
public record WindowParameter(Type Type);
When the user opens a window, an entry is added to this collection, and is rendered like this...
@foreach (WindowParameters w in Windows) {
<DynamicComponent Type="@w.Type" />
}
The real code has much more complexity, but I think this is enough to explain my question.
There are times when the window manager needs to pass some data to a specific window. However, it doesn't have a list of the window components, so can't do that directly. I'm trying to find a way of doing this.
I tried wrapping the foreach
loop above in a <CascadingValue>
, passing this
as the value, but the cascading parameter in the window components was always null.
I thought of looping through the child components of the window manager, looking for components that inherit from WindowBase
, but couldn't find a way to do that.
Anyone able to help?