0

我想为 Monotouch 开发一个类似于BTProgressHud的小型可重用组件。但我目前停留在如何在不干扰页面内容的情况下将叠加层注入可视化树。

更新:

经过一段时间的试验,我想出了一个想法,以便能够将叠加层与页面内容分离,将窗口内容从框架更改为可以同时托管根框架和任何通知元素的网格.

应用程序.xaml.cs

protected override async void OnLaunched(LaunchActivatedArgs args)
{
  Grid rootGrid = Window.Current.Content as Grid;

  if(rootGrid == null)
  {
    var rootFrame = new Frame();

    rootGrid = new Grid();
    rootGrid.Children.Add(rootFrame);
    Window.Current.Content = rootGrid;
  }
}

ProgressHud.cs

public static class ProgressHud
{
  static void Show(string msg)
  {
    Grid rootGrid = Window.Current.Content as Grid;

    // just for testing the concept
    rootGrid.Children.Add(new ProgressRing { IsActive = true };
  }
}

任何人都可以确认将 Window.Content 根从框架更改为网格会导致不需要的副作用吗?

在此处输入图像描述

4

1 回答 1

1

在某种程度上取决于您页面的其余部分是什么样的,但是像这样的覆盖控件通常可以作为最后一个元素放在页面上的主容器中(无论是网格还是画布或其他)(所以它将是z 顺序中的最高点),然后设置为不可见/折叠(直到需要)。折叠时不会干扰您的其他内容。

于 2013-07-10T19:42:51.310 回答