I have a requirement where in I need to display a list in a modal popup page.I am able to display a list but I cant make the background color transparent or semi transparent so that the page under it is partially visible.
I am pushing the page from my View Model using the folowing:
NavigationParameters oNavParams = new NavigationParameters();
oNavParams.Add("Mode", "FeedBack");
oNavParams.Add("selectedItem", txtFeedback);
_navigationService.NavigateAsync("PopupBox", oNavParams);
Here is my xaml code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
xmlns:local="clr-namespace:MyApp"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="MyApp.Views.PopupBox">
<ContentPage.Content>
<AbsoluteLayout Padding="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<ContentView x:Name="popupListView" BackgroundColor="Transparent" Padding="10, 0" IsVisible="false" AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All">
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<StackLayout Orientation="Vertical" HeightRequest="200" WidthRequest="300" BackgroundColor="White">
<ListView x:Name="sampleList">
</ListView>
</StackLayout>
</StackLayout>
</ContentView>
</AbsoluteLayout>
</ContentPage.Content>
</ContentPage>
Here is my code behind:
public PopupBox()
{
try
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
sampleList.ItemsSource = new List<string>
{
"Test ListView",
"Test ListView",
"Test ListView",
"Test ListView",
"Test ListView",
"Test ListView",
"Test ListView",
"Test ListView",
"Test ListView",
"Test ListView",
"Test ListView"
};
popupListView.IsVisible = true;
}
catch (Exception ex)
{
}
}
I have also tried setting the following:
this.BackgroundColor= new Color(0, 0, 0, 0.4);
But it does not work.Is there any way I can achieve this?Using custom renderers or any other workaround to display a modal. I don't wan't to use the Rg.Plugins.Popup as I had issues with it.So I was looking for an alternative.Please help.