我使用以下XAML代码在ListView中呈现一些数据:
<ListView x:Name="myListView"
ItemsSource="{Binding myData}"
RowHeight="230">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<RelativeLayout Padding="1">
<StackLayout x:Name="stackLayoutTitle"
Padding="5"
Orientation="Vertical"
VerticalOptions="EndAndExpand"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.6}">
<Label Text="{Binding myText}"
FontSize="Medium"
FontAttributes="Bold"
TextColor="Black">
</Label>
</StackLayout>
</RelativeLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
数据呈现正常 . 现在,我想要做的是使用banding作为RelativeYConstranit的Factor属性,根据一些计算来定位相应的StackLayout . 像这样的东西 (see the Factor property):
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor={Binding someValue}}"
但是,当运行应用程序时,我收到一个错误 .
有谁知道是否可以使用绑定表达式?
谢谢 .
2 回答
我有这个问题 . “因素”不是BindingProperty . 因此现在是不可能的 .
我尝试了类似的事情,并没有为YConstraint绑定因子,这里解释了为什么它不起作用
从文档:
我收到的错误消息:
结论:没有可绑定属性(请注意它必须是可绑定属性,否则您无法绑定)底层代码中的因子因此无法绑定 .