2016-05-01 39 views
9

Ben Xamarin.forms kullanıyorum ve aşağıdaki resimdeki gibi bir pop-up görünümünde bir giriş şeklinin bulunması gerekir: Şu anda PushModalAsync kullanıyorumBir formda xamarin.forms kullanarak bir form nasıl oluşturulur?

https://github.com/michaeled/FormsPopup/blob/master/pictures/androidPopup.gif?raw=true

Ancak bu yeni sayfayı yapar formu ile, sadece istediğim gibi bir pop-up görünümü göstermek yerine, tüm ekranı kapsamaktadır.

Bunu xamarin.forms kullanarak yapmak için herhangi bir yolu var mı? Değilse, halihazırda uygulanan herhangi bir çapraz platform (Android, iOS ve UWP) alternatifi var mı?

cevap

11

Benim deneyim diyor XLabs' PopupLayout doesn't work properly sometimes. Ancak, karmaşık pop-up'lar oluşturmaya izin veren gerçekten güzel bir kütüphane var: Rg.Plugins.Popup. Tek sorun: UWP uygulaması eksik (ama going to be released).

+0

Yardımın için teşekkürler, ancak bu durumda uwp uygulaması gerekiyor. –

+1

[Rg.Plugins.Popup] (https://github.com/rotorgames/Rg.Plugins.Popup) Prerelease (1.0.0-pre1) zaten WinPhone ve UWP'yi destekler. Beta testine katılmayı kabul ederseniz memnun olurum. – user1658602

4

XLabs, bunu yapmak için kullanabileceğiniz bir PopupLayout'a sahiptir.

  var pop = new XLabs.Forms.Controls.PopupLayout(); 

      // PatientSearch is a ContentView I was to display in the popup 
      var search = new PatientSearch(data, this); 
      search.WidthRequest = 600; 
      search.HeightRequest = 500; 
      search.BackgroundColor = new Color (1, 1, 1, 0.8); 
      pop.ShowPopup(search); 
+0

Cevabınız için teşekkür ederiz. Ne yazık ki bir hata alıyorum NullReferenceException (https://github.com/XLabs/Xamarin-Forms-Labs/issues/1107#issuecomment-197701086). Bunu nasıl çözeceğinizi biliyor musunuz? –

0

ben kullandım ortak bir çözüm bu örnek için, içindeki tüm form ile bir StackLayout oluşturup ona kullanmakta olduğunuz Sayfası'nda bir çocuk eklemek çözmek için kullanılan şudur:

PopupPage popUp; //This will be the layout of the form 

Page : ContentPage { 

    var gird = new Gird(); 

    popUp = PopupPage(); 
    popUp.IsVisible = false; 

    var mainContainer = new StackLayout(); 

    mainContainer.Children.Add(All you UI stuff..); 

    var btn = new Button(); 
    btn.Clicked += OnButtonClicked; 

    grid.Children.Add(mainContainer,0,0); 
    grid.Children.Add(popUp,0,0); 

} 

So in order to show the popoUP you need to play with the IsVisible property, for example: 

void OnButtonClicked(){ 

    //You can center the popup using Vertical options or whatever you need 
    //and to resize the pop up you can do different calculations like 
    //popUp.Width = ScreenWidth/2 and popUp.Height = ScreenWidth/2 
    popUp.IsVisile = true; 

} 

Ve bu tüm platformlar için çalışır, tek dezavantajı şeffaf bir düzen olmayacağını, ancak bunun için kullanabilirsiniz:

https://github.com/gaborv/xam-forms-transparent-modal

İlgili konular