Hi,
I have error
Views\RouteList.xaml(101,40): XamlC error XFC0045: Binding: Property "RouteStatusName" not found on "Models.Responses.GetRouteListResponseBase".
This error is after I add new properties to model and try binding this prop. My Model is in another assembly:
namespace Models.Responses
{
public class GetRouteListResponseBase
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime PlannedDate { get; set; }
public double Distance { get; set; }
public RouteStatus RouteStatus { get; set; }
public string RouteStatusName { get; set; }
[JsonIgnore]
public bool Today => PlannedDate == DateTime.Today;
[JsonIgnore]
public bool Late
{
get
{
return PlannedDate < DateTime.Today;
}
}
[JsonIgnore]
public bool Future
{
get
{
return PlannedDate > DateTime.Today;
}
}
}
}
And here is my XAML. What I do wrong?
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="nMscoutApp.Views.RouteList"
xmlns:response="clr-namespace:Models.Responses;assembly=Models"
xmlns:vm="clr-namespace:nMscoutApp.ViewModels"
Title="{Binding Title}">
<ContentPage.BindingContext>
<vm:RouteListViewModel />
</ContentPage.BindingContext>
<ContentPage.ToolbarItems>
<ToolbarItem Text="Odśwież" Command="{Binding RefreshCommand}" />
</ContentPage.ToolbarItems>
<StackLayout>
<RefreshView x:DataType="local:RouteListViewModel" Command="{Binding LoadItemsCommand}" IsRefreshing="{Binding IsBusy, Mode=TwoWay}">
<ListView x:Name="listView" CachingStrategy="RecycleElement"
ItemsSource="{Binding Routes}"
Grid.Row="2"
HasUnevenRows="true"
SeparatorVisibility="None">
<ListView.Resources>
<Style TargetType="{x:Type Frame}">
<Style.Triggers>
<DataTrigger TargetType="{x:Type Frame}"
Binding="{Binding Late}"
Value="true">
<Setter Property="Background"
Value="LightGray"/>
</DataTrigger>
<DataTrigger TargetType="{x:Type Frame}"
Binding="{Binding Future}"
Value="true">
<Setter Property="Background"
Value="LightGreen"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.Resources>
<!--<ListView.Behaviors>
<b:EventToCommandBehavior EventName="ItemTapped"
Command="{Binding OnItemTappedCommand}"
EventArgsConverter="{converters:ItemTappedEventArgsConverter}"/>
</ListView.Behaviors>-->
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell x:DataType="response:GetRouteListResponseBase">
<Frame BorderColor="White" Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.RowSpan="2"
Grid.Row="0"
Grid.Column="0"
Text="{Binding Name}"
FontSize="Large"
LineBreakMode="TailTruncation"/>
<Label VerticalTextAlignment="Center"
HorizontalTextAlignment="End"
Grid.Row="0" Grid.Column="1"
Text="{Binding PlannedDate, StringFormat='{0:dd-MM-yyyy}'}"
FontSize="Medium"
TextColor="Gray"
LineBreakMode="TailTruncation"/>
<Label VerticalTextAlignment="Center"
HorizontalTextAlignment="End"
Grid.Row="1" Grid.Column="1"
Text="{Binding Distance, StringFormat='{0:N} km'}"
FontSize="Medium"
TextColor="Gray"
LineBreakMode="TailTruncation"/>
<Label VerticalTextAlignment="Center"
HorizontalTextAlignment="Start"
Grid.Row="2"
Grid.Column="0"
Text="{Binding RouteStatusName}"
FontSize="Medium"
TextColor="Gray"
LineBreakMode="TailTruncation"/>
</Grid>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</RefreshView>
</StackLayout>
</ContentPage>
Error is with last Label (Text="{Binding RouteStatusName}").