我的问题如下:我有ContentPage一个ResourceDictionary带有一些
DataTemplates 的我。其中一个模板采用HorseObject(其中包含List<Weight>'s)。我显示了该对象的几个统计信息,但是当我想将变量从Horse对象传递到另一个视图时,如下所示:
<graph:LineGraph x:Name="displayWeight" WeightOfHorse="{Binding Weight}"/>
代码背后WeightOfHorse:
public static readonly BindableProperty WeightOfHorseProperty = BindableProperty.Create(
nameof(WeightOfHorse),
typeof(IList<Weight>),
typeof(LineGraph),
defaultBindingMode: BindingMode.TwoWay);
public IList<Weight> WeightOfHorse
{
get => (IList<Weight>)GetValue(WeightOfHorseProperty);
set => SetValue(WeightOfHorseProperty, value);
}
我只是无法传递这些值,我知道它们是可用的,因为我可以将它们显示在一个简单的Collectionview.
我究竟做错了什么?