- Home
- Forum
- Xamarin.Forms
- SfPopupLayout and SfBusyInidcator not show up only in UWP release build
SfPopupLayout and SfBusyInidcator not show up only in UWP release build
My Xamarin.Forms app need to show a modal with a busy indicator whenever needed. They show up just fine in UWP debugger but not show up in UWP release mode.
I have a class called BusyIndicator:
using iTrak4.Mobile.XamarinForms.Common;
using Syncfusion.XForms.PopupLayout;
using Syncfusion.SfBusyIndicator.XForms;
using Xamarin.Forms;
using System;
using Xamarin.Essentials;
[assembly: Dependency(typeof(BusyIndicator))]
namespace iTrak4.Mobile.XamarinForms.Common
{
public class BusyIndicator : IBusyInfo
{
private SfBusyIndicator _busyIndicator;
private SfPopupLayout _popupLayout;
private IScreenSize _screenSize;
public BusyIndicator()
{
_screenSize = DependencyService.Get<IScreenSize>();
if (_screenSize != null)
{
_screenSize.SizeChanged += OnSizeChanged;
}
InitializePopupLayout();
}
private void InitializePopupLayout()
{
_busyIndicator = new SfBusyIndicator
{
AnimationType = AnimationTypes.HorizontalPulsingBox,
ViewBoxWidth = 100,
ViewBoxHeight = 100,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
TitlePlacement = TitlePlacement.Bottom,
TextColor = (Color)Application.Current.Resources["ITRAKBlue"]
};
var displayInfo = DeviceDisplay.MainDisplayInfo;
_popupLayout = new SfPopupLayout
{
PopupView =
{
BackgroundColor = Color.FromRgba(0, 0, 0, 0.1),
ShowHeader = false,
ShowCloseButton = false,
ShowFooter = false,
IsFullScreen = true,
ContentTemplate = new DataTemplate(() =>
{
var grid = new Grid
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
grid.Children.Add(_busyIndicator);
return grid;
})
}
};
}
private void OnSizeChanged(object sender, EventArgs e)
{
Device.BeginInvokeOnMainThread(() =>
{
_popupLayout.PopupView.HeightRequest = _screenSize.GetHeight();
_popupLayout.PopupView.WidthRequest = _screenSize.GetWidth();
});
}
public void Show(string text)
{
Device.BeginInvokeOnMainThread(() =>
{
_busyIndicator.Title = text;
_popupLayout.IsOpen = true;
});
}
public void Update(string text)
{
Device.BeginInvokeOnMainThread(() =>
{
_busyIndicator.Title = text;
});
}
public void Hide()
{
Device.BeginInvokeOnMainThread(() =>
{
_popupLayout.IsOpen = false;
});
}
}
}
In the App.xaml.cs file of the shared project, I have a method to show the busy indicator:
public static async Task<IBusyInfo> ShowBusyMessageAsync(string message)
{
var busyInfo = DependencyService.Get<IBusyInfo>();
await Task.Run(() =>
{
Xamarin.Forms.Device.BeginInvokeOnMainThread(() => busyInfo?.Show(message));
});
return busyInfo;
}
In the MainPage.xmal.cs file of the UWP project, I initilize the SfPopupLayout by this:
namespace iTrak4.Mobile.UWP
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage
{
public MainPage()
{
this.InitializeComponent();
var app = new iTrak4.Mobile.XamarinForms.App();
BackButtonTool.FixBackButtonAppearence(app);
NavigationBarTool.FixNavigationBarVisibility(app);
CachedImageRenderer.Init();
SfListViewRenderer.Init();
Syncfusion.SfDataGrid.XForms.UWP.SfDataGridRenderer.Init();
Syncfusion.XForms.UWP.PopupLayout.SfPopupLayoutRenderer.Init();
Xamarin.Forms.DependencyService.Register<ILocalSettings, LocalSettings>();
LoadApplication(app);
}
}
}
In the App.xaml.cs file of UWP project, I also initialize the SfPopupLayout and SfBusyIndicator assemblies like this:
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
InitializeAppComponents(e);
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
rootFrame = InitializeRootFrame(e);
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
UnregisterAttachmentUploadTask();
RegisterManuallyTriggeredTask();
// Ensure the current window is active
Window.Current.Activate();
if (e.PrelaunchActivated == false)
{
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
}
private Frame InitializeRootFrame(IActivatedEventArgs args)
{
// Create a Frame to act as the navigation context and navigate to the first page
Frame rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
List<Assembly> assembliesToInclude = new List<Assembly>
{
typeof(SfPopupLayoutRenderer).GetTypeInfo().Assembly,
typeof(SfBusyIndicatorRenderer).GetTypeInfo().Assembly,
typeof(CachedImage).GetTypeInfo().Assembly,
typeof(CachedImageRenderer).GetTypeInfo().Assembly,
typeof(SfButtonRenderer).GetTypeInfo().Assembly,
typeof(SfBorderRenderer).GetTypeInfo().Assembly,
typeof(SfTextInputLayoutRenderer).GetTypeInfo().Assembly,
typeof(SfCheckBoxRenderer).GetTypeInfo().Assembly,
typeof(SfDatePickerRenderer).GetTypeInfo().Assembly,
typeof(SfComboBoxRenderer).GetTypeInfo().Assembly,
typeof(SfListViewRenderer).GetTypeInfo().Assembly,
typeof(SfImageEditorRenderer).GetTypeInfo().Assembly,
typeof(SfExpanderRenderer).GetTypeInfo().Assembly,
typeof(Fonts.Fonts).GetTypeInfo().Assembly,
typeof(SfDataGridRenderer).GetTypeInfo().Assembly,
typeof(SfNumericTextBoxRenderer).GetTypeInfo().Assembly,
typeof(SfTabViewRenderer).GetTypeInfo().Assembly
};
Xamarin.Forms.Forms.Init(args, assembliesToInclude);
return rootFrame;
}
The Syncfusion.Xamarin.SfBusyIndicator and SfPopupLayout packages are the 26.2.9 and Xamarin.Forms version is 5.0.0.2662
My issue is: the popup and busy indicator work fine in debugger mode, but never show up in the release build for UWP platform.
Hi Chen Li,
We would like to inform you that we have prepared a simple sample based on your reported query and have tested the issue under the following scenarios:
- Showing the popup from the constructor.
- Showing the popup from the OnAppearing()
method. - Showing the popup on a button click.
We encountered an issue where, when showing the popup from the constructor, both the SfPopup and the SfBusyIndicator do not appear in the view in Release mode. However, the remaining cases are working as expected.
Could you please provide additional details about how you are showing the popup? If possible, kindly share a sample project to help us validate the issue. This will allow us to investigate further and provide a solution as soon as possible.
Regards,
KamalaKannan S.
- 1 Reply
- 2 Participants
-
CL Chen Li
- Aug 15, 2024 09:11 PM UTC
- Aug 16, 2024 02:55 PM UTC