Xamarin UWP Set HUD load Feature

Source: Internet
Author: User

Using Xamarin for development often uses the load HUD function, which is one of our common loading actions, using Andhud under Android, and using Btprogresshud under IOS, both on NuGet. The way it is provided in the UWP itself does not fully meet our needs, so we need to use dependencies to redefine the HUD functionality of the platform, which can be done using the Popup . The popup itself is a popup control that allows you to add a variety of other controls to the control, which makes it easy for us to customize pop-up windows. First, we'll set the popup size to the size of the area that the app sees. In the middle of the popup, load a grid,grid inside to load the required text and pictures can come. The instance code is as follows:

usingBS. Dependencies;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingxamarin.forms;usingWindows.UI.Xaml.Controls;usingWindows.UI.Xaml.Controls.Primitives;usingWindows.UI.Xaml.Media;usingWindows.ui;usingWindows.UI.Xaml; [Assembly:dependency (typeof(BS. UWP. DEPENDENCIES.HUDUWP)]namespaceBS. UWP. dependencies{ Public classHuduwp:ihud {PrivateWindows.UI.Xaml.Controls.Grid Container =NewWindows.UI.Xaml.Controls.Grid () {Background=NewSolidColorBrush (colors.black), Cornerradius=NewCornerradius (Ten), Padding=NewWindows.UI.Xaml.Thickness (Ten), HorizontalAlignment=HorizontalAlignment.Center, VerticalAlignment=Verticalalignment.center,}; PrivatePopup popup =NULL;  Publichuduwp () { This. Popup =NewPopup () { child=NewBorder () {Width=Window.Current.Bounds.Width, Height=Window.Current.Bounds.Height, Background=NewSolidColorBrush (Colors.gray), Opacity=0.6, HorizontalAlignment=HorizontalAlignment.Center, VerticalAlignment=Verticalalignment.center, child= This.        Container,}}; }         Public voidShow () { This. Show ("Hello World",60000); }         Public voidShow (stringmessage) {             This. Show (Message,60000); }         Public voidShow (stringMessageintDelay = +)        {             This. Popup.isopen =true;  This.                        Container.Children.Clear ();  This. CONTAINER.CHILDREN.ADD (NewTextBlock () {Text=message, Foreground=NewSolidColorBrush (colors.white), FontSize= -            }); }         Public voidDismiss () { This. Popup.isopen =false; }    }}

Already on the code after I test can be used, hope to develop useful for you. At the same time, the above code can be used under the win8.1 and Winphone platforms. If there is a better way, please leave a message.

Xamarin UWP Set HUD load Feature

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.