2017-01-02 10 views
0

私はXamarinフォームプロジェクトに取り組んでおり、いくつかのポップアップを開く問題で立ち往生しています。 FormsはPopupをビルドしていないので、別のXAMLページがあり、MainPage.XAMLの中にそれらをロードし、必要に応じて可視性を変更します。ナビゲーションでのXamarinフォームの遅延

**Popup_1.XAML** 

<?xml version="1.0" encoding="utf-8" ?> 
<StackLayout xmlns="http://xamarin.com/schemas/2014/forms" 
xmlns:x=http://schemas.microsoft.com/winfx/2009/xaml 
x:Class="ABC.Views.Popup_1"> 

<StackLayout > 
<Label Text="{Binding FirstName}" VerticalOptions="CenterAndExpand" HorizontalOptions="StartAndExpand" Font="Large" TextColor="Black" /> 
</StackLayout> 

</StackLayout> 

私はそれらをポップアップとして表示したいと思うPopup_1のようなレイアウトがたくさんあります。ここに私のMainPage.XAMLは3つのポップアップレイアウトを含んでいます。

**MainPage.XAML** 

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPagexmlns="http://xamarin.com/schemas/2014/forms" 
xmlns:x=http://schemas.microsoft.com/winfx/2009/xaml 
xmlns:controls="clr-namespace:ABC.Views;assembly=ABC" 
x:Class="ABC.Views.MainPage"> 

<AbsoluteLayout BackgroundColor="Transparent" Padding="10" IsVisible="{Binding ShowPopup_1}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" > 
     <StackLayout Orientation="Horizontal" BackgroundColor="Transparent" AbsoluteLayout.LayoutBounds="0.5, 0.5, -1, -1" AbsoluteLayout.LayoutFlags="PositionProportional" > 
      <controls:Popup_1 /> 
     </StackLayout> 
    </AbsoluteLayout> 


<AbsoluteLayout BackgroundColor="Transparent" Padding="10" IsVisible="{Binding ShowPopup_2}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" > 
     <StackLayout Orientation="Horizontal" BackgroundColor="Transparent" AbsoluteLayout.LayoutBounds="0.5, 0.5, -1, -1" AbsoluteLayout.LayoutFlags="PositionProportional" > 
      <controls:Popup_2 /> 
     </StackLayout> 
    </AbsoluteLayout> 

<AbsoluteLayout BackgroundColor="Transparent" Padding="10" IsVisible="{Binding ShowPopup_3}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" > 
     <StackLayout Orientation="Horizontal" BackgroundColor="Transparent" AbsoluteLayout.LayoutBounds="0.5, 0.5, -1, -1" AbsoluteLayout.LayoutFlags="PositionProportional" > 
      <controls:Popup_3 /> 
     </StackLayout> 
    </AbsoluteLayout> 


</ContentPage> 

問題は、Mainpage.XAMLにナビゲートしようとしているときにナビゲートするのに時間がかかることです。この問題の標準的な解決策はありますか?またはこの遅延をどのように処理できますか? 注:私は、フォームのようなレイアウト

答えて

0

の可視性を変更するためにMVVM結合パターンを使用していることは、ビルドポップアップで

を持っていないドキュメント

https://developer.xamarin.com/guides/xamarin-forms/user-interface/navigation/pop-ups/

+0

これらは唯一のアラートボックスまたはアクションシートです。プロジェクトで必要なポップアップではありません。 ViewModelにバインドされた異なるフィールドを持つ独自のレイアウトを持つ必要があります。 –

0

のこのページを参照してください。 ContentPageを使用して独自のポップアップダイアログをカスタマイズするのは正しいですが、このカスタムダイアログを表示する通常の方法は、あなたの親要素の可視性を設定することではありませんrダイアログ。 PushModalAsyncを使用してそれを表示し、PopModalAsyncを使用してそれを却下する必要があります。

コードサンプルについては、PushModalAsyncまたはPopModalAsyncを参照してください。

ダイアログの後ろにコードを投稿していないので、ナビゲーションが遅れる原因となるUIがブロックされているかどうかはわかりません。とにかく、モーダルページをプッシュしポップして、これが役立つかどうかを調べることができます。

関連する問題