【发布时间】:2020-09-26 15:52:49
【问题描述】:
我的问题如下:
我有我的ContentPage,其中有一个ResourceDictionary 和一些
DataTemplates。其中一个模板采用Horse 对象(其中包含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 中。
我做错了什么?
【问题讨论】:
标签: c# xaml xamarin xamarin.forms bindableproperty