我试图在C#中使用前端XAML代码。当我尝试将activity indicator
与IsBusy
绑定时无法实现它。
我希望在页面繁忙时弹出活动指示器。
答案 0 :(得分:0)
这篇文章是为了展示如何在后端C#代码中使用 scrollview 和指标来实现基本屏幕。
分配给滚动内容的布局是我们根据要求设计的任何基本布局。这是我的代码示例:
#region render
scroll = new ScrollView
{
Content = layout
};
AbsoluteLayout.SetLayoutBounds(scroll, new Rectangle(0, 0, 1, 1));
AbsoluteLayout.SetLayoutFlags(scroll, AbsoluteLayoutFlags.All);
AbsoluteLayout screenMask = new AbsoluteLayout { BackgroundColor = Color.FromHex("#22000000") };
screenMask.BindingContext = this;
screenMask.SetBinding(IsVisibleProperty, "IsBusy", BindingMode.OneWay);
AbsoluteLayout.SetLayoutBounds(screenMask, new Rectangle(0.5, 0.5, 1, 1));
AbsoluteLayout.SetLayoutFlags(screenMask, AbsoluteLayoutFlags.All);
ActivityIndicator indicator = new ActivityIndicator { Color = Color.Black };
indicator.BindingContext = this;
indicator.SetBinding(IsVisibleProperty, "IsBusy",BindingMode.OneWay);
indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
AbsoluteLayout.SetLayoutBounds(indicator, new Rectangle(0.5, 0.5, 0.1, 0.1));
AbsoluteLayout.SetLayoutFlags(indicator, AbsoluteLayoutFlags.All);
Content = new AbsoluteLayout
{
Children = { scroll, screenMask, indicator }
};
#endregion
希望这可以帮助很多人。