我正在使用服务从json获取一些值。 我将它们显示在主页(IrrigNetPage)上,其中有三个标签,因此我想在每个标签上以不同的方式对它们进行排序。
这是我的模特:
a) ObjectMapper mapper = new ObjectMapper();
b) mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
c) mapper.writeValueAsString(EmployeeListobjects);
这是View中xaml代码的一部分:
public class IrrigNetModel
{
public IrrigNetModelItem[] items { get; set; }
}
public class IrrigNetModelItem
{
public int ID { get; set; }
public string Message { get; set; }
public DateTime Date { get; set; }
public string DateText { get; set; }
public int StationId { get; set; }
public string StationName { get; set; }
public float StationLongitude { get; set; }
public float StationLatitude { get; set; }
public int ServiceId { get; set; }
public string ServiceName { get; set; }
}
当然,这是ViewModel的一部分:
<StackLayout
Grid.Column="1"
Orientation="Horizontal"
HorizontalOptions="FillAndExpand"
BackgroundColor="{Binding LocationTabColor}"
Padding="10"
Margin="1">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TabTappedCommand}" CommandParameter="location"/>
</StackLayout.GestureRecognizers>
<Image Source="{Binding LocationTabIcon}"
HorizontalOptions="Start"
VerticalOptions="Center"
WidthRequest="16"
HeightRequest="16"
Aspect="AspectFit"
x:Name="LocationIcon"/>
<Label Text="{i18n:Translate Location}"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
TextColor="{Binding LocationTabTextColor}"/>
</StackLayout>
在其中设置一些比例值的地方,如您在此处看到的,我将方法称为GroupServicesByLocation();。看起来像这样:
else if (tabName == "location")
{
ServiceTabColor = Color.FromHex("#f4f4f4");
LocationTabColor = Colors.MENU_SELECTED_ITEM;
MapTabColor = Color.FromHex("#f4f4f4");
ServiceTabIcon = "services.png";
LocationTabIcon = "location_sel.png";
MapTabIcon = "location.png";
ServiceTabTextColor = Colors.MENU_SELECTED_ITEM;
LocationTabTextColor = Color.FromHex("#ffffff");
MapTabTextColor = Colors.MENU_SELECTED_ITEM;
ListHederIcon = "location.png";
IsListVisible = IsListVisible;
IsGridHeaderVisible = true;
IsMapVisible = false;
if (ServiceName == "irrigNET")
{
FrameIcon = "service_irrig.png";
}
else
{
FrameIcon = "service_trap.png";
}
GroupServicesByLocation();
}