如何在 Blazor 中禁用组件层次结构?

问题描述

我想实现与 WPF 应用程序类似的效果,其中您有一个 XAML 层次结构,禁用其中一个祖先也会使其所有子代也被禁用。

我在 Blazor 组件中找不到任何类似的方法。
我试图研究级联参数和值,但我不确定我是否在正确的轨道上。

假设我有一个如下所示的组件层次结构:

<PanelContainer Title="Upload log file">
   <ParagraphRow ParagraphType="ParagraphType.Paragraph1" Label="Some test row">
      <EditBox Text="Some test text" />
   </ParagraphRow>
   <ParagraphRow ParagraphType="ParagraphType.Paragraph2" Label="Some fancy test row disabled" IsEnabled="false">
      <EditBox Text="Some fancy test text" />
   </ParagraphRow>
   <ParagraphRow ParagraphType="ParagraphType.Paragraph3" Label="Some other test row">
      <EditBox Text="Some disabled test text" IsEnabled="false" />
   </ParagraphRow>
</PanelContainer>

这里的所有组件都继承自一个基本组件类,其中 IsEnabled 属性被声明为公共属性。
每个组件应根据其 IsEnabled 值表现不同。

例如:
EditBox 应该禁用内部输入 HTML 标签,将 CSS 类附加到包装器标签等。 如果我只是禁用 EditBox 本身,它就像一个魅力,没什么特别的(第三个 ParagraphRow)。
我想在第二个 ParagraphRow 中获得相同的结果,其中行本身已被禁用。在这里,我想对 row 组件(标签的 CSS 类、验证逻辑更改等)进行一些禁用逻辑,但我也希望它的子项({{ 1}} 在这种情况下)也会以某种方式“通知”有关被禁用的信息,因此它可以自行更新为禁用状态。

我更喜欢一种解决方案,我不必在所有地方都抛出绑定和级联值 EditBox,因此它可以“正常工作”开箱即用。
在 Blazor 架构中甚至可能吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...