Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

How to pass default values?

$
0
0

Hi, greetings for the day.
I am beginner. Basically, I am designing filters page where I need to pass some default vales from FiltersPage.xaml.cs to ItemListPage.xamsl.cs so that user gets a list of items based on filters applied. I am getting an exception when user does not check some filter option, so I have to pass a default values to avoid run time exception.

FiltersPage.xaml.cs

public partial class FiltersPage : ContentPage
{
public class Cost
{
public string costBelow { get; set; }
public string costAbove { get; set; }
}

    public List<Cost> cost = new List<Cost>()
    {
    new Cost{costAbove=" 0 ",costBelow="249999"},
    new Cost{costAbove=" 250000  ",costBelow=" 269999"},
    new Cost{costAbove=" 270000  ",costBelow=" 289999"},
    new Cost{costAbove=" 290000  ",costBelow=" 300999"},
    new Cost{costAbove=" 310000  ",costBelow=" 320999"},
    new Cost{costAbove=" 330000  ",costBelow=" 340999"},
    new Cost{costAbove=" 350000  ",costBelow="1000000"},
    };

    List<string> s = new List<string>();
    List<string> se = new List<string>();
    Cost c { get; set; } 
    public FiltersPage()
    {
        InitializeComponent();
}
  private void ApplyFilters_Clicked(object sender, EventArgs e)
    {
        Navigation.PushAsync(new ItemListPage(s, se, c));
    }

}

ItemListPage.xamsl.cs

public partial class ItemListPage : ContentPage
{
List sa = new List();
List se = new List();
Cost c;
public ItemListPage(List sa, List se, Cost c)
{
InitializeComponent();
this.sa = sa;
this.se = se;
this.c = c;
GetCarFilter();

    }

}

This is how my filters pages looks like. I want to pass default vales for all 3.

Thanks in advance.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>