MAUI - 以编程方式更改子对象

问题描述 投票:0回答:1

我想通过代码更改某些属性(从数据库获取数据)...

作为测试,我尝试过这个解决方案

  View v = this.Content;
  List<IVisualTreeElement> elements = (List<IVisualTreeElement>)v.GetVisualTreeDescendants();
  foreach (IVisualTreeElement button in elements)
  {
      if (button is Button)
      {
          Button myButton= (Button)button;
          myButton.IsVisible = false;
          myButton.TextColor = Colors.DeepPink;
      }
  }

但不起作用(不知道为什么......)

我能做什么?

Google 和文档搜索,

dynamic components maui child-objects
1个回答
0
投票

有时...经过 4 次我用断点等进行编译后...有效。别问我为什么。

© www.soinside.com 2019 - 2024. All rights reserved.