2つのピンをグループに分ける必要があります。なぜなら、それらをフィルタリングするとき、どのピンがどのカテゴリに属するのかを知る必要があるからです。データから受け取っているピンを別のカテゴリに分けるにはどうしたらいいですか?
これは私がそれらを受け取る方法です。したがって、int app.value1が0で、もう1つがapp.value2が0の場合はロードするグループが1つあります。
私はそれらを分離する必要がある理由は、私が分離する必要があるためです二つ。多分2つの異なるリストをしなければならないでしょうか?それとも良い方法がありますか?
List<Pin> myPins = new List<Pin>();
private async Task<List<Pin>> LoadData()
{
var pins = new List<Pin>();
var getItems = await phpApi.getInfo();
foreach (var currentItem in getItems["results"]) {
longString = currentItem ["long"].ToString();
latString = currentItem ["lat"].ToString();
if (App.value1 == 0) { //so this below is the first group of pins then
var pin = new Pin();
pin.Position = new Position (latString, longString);
pin.Label = "testlabel";
pin.Address = "testadress";
pins.Add (pin);
}
if (App.value2 == 0) { //second group of pins
//i add pins here as well (so the same code as App.value1), but this intvalue is connected to a different "button"
pins.Add (pin);
}
}
}
とピンdoesntのは、インクルードが属するグループを知っているので、これは今働いていない私のフィルタである:
private async void FilterPins (string filter)
{
map.Pins.Clear();
foreach(Pin p in myPins) {
if (string.IsNullOrWhiteSpace(filter) || (p.Label.Contains(filter))) {
map.Pins.Add (p); //this is just a searchfilter via my searchbar that isnt working when I add the code below. If i remove the code below this function works.
}
if (App.value1 == 0) {
map.Pins.Add (p);
System.Diagnostics.Debug.WriteLine ("add");
}
if (App.value2 == 0) {
map.Pins.Add (p);
System.Diagnostics.Debug.WriteLine ("add");
}
}
}
うん、私はこのの助けを借りてそれを解決するために管理しました。すごい、thx – Yannick