我有一个作为 o 模型的类: Flight 和 flightDetails 类是在 web 服务的代理中定义的两个类:
public class FlightView
{
public FlightView()
{
FlightDetailsElement = new FlightDetails();
Flight = new Flight();
VisibleBoarding = false;
VisibleCheckIn = false;
Visibleluggage = false;
}
public Flight Flight;
public FlightDetails FlightDetailsElement;
private bool _visibleCheckIn;
public bool VisibleCheckIn
{
get { return _visibleCheckIn; }
set { _visibleCheckIn = value; }
}
private bool _visibleBoarding;
public bool VisibleBoarding
{
get { return _visibleBoarding; }
set { _visibleBoarding = value; }
}
private bool _visibleluggage;
public bool Visibleluggage
{
get { return _visibleluggage; }
set { _visibleluggage = value; }
}
private DateTime _refreshDate;
public DateTime RefreshDate
{
get { return _refreshDate; }
set { _refreshDate = value; }
}
private string _date;
public string Date
{
get { return _date; }
set { _date = value; }
}
private string _time;
public string Time
{
get { return _time; }
set { _time = value; }
}
}
在代码隐藏中,我设置了网格的 dataxontext:
SelectedFlightView.FlightDetailsElement = e.Result;
if(!(SelectedFlightView.FlightDetailsElement.IsArrival) && !string.IsNullOrEmpty(SelectedFlightView.FlightDetailsElement.BoardingGate))
SelectedFlightView.VisibleBoarding= true;
if(!(SelectedFlightView.FlightDetailsElement.IsArrival) && !string.IsNullOrEmpty(SelectedFlightView.FlightDetailsElement.CheckInArea))
SelectedFlightView.VisibleCheckIn= true;
if ((SelectedFlightView.FlightDetailsElement.IsArrival) && !string.IsNullOrEmpty(SelectedFlightView.FlightDetailsElement.LuggageDelivery))
SelectedFlightView.Visibleluggage = true;
SelectedFlightView.RefreshDate = DateTime.Now;
SelectedFlightView.Date = SelectedFlightView.RefreshDate.ToLongDateString();
SelectedFlightView.Time = SelectedFlightView.RefreshDate.ToLongTimeString();
ContentPanelDetails.DataContext = SelectedFlightView;
我的问题是当我在 xaml 中绑定时:
<TextBlock Text="{Binding FlightDetailsElement.DepartureTime}"/>
我没有结果,但是当我绑定时
<TextBlock Text="{Binding Time}"/>
我有结果。
请问有什么想法吗??
问候