【发布时间】:2014-12-04 20:41:20
【问题描述】:
我正在尝试复制 following example 以了解 Xamarin 中的绑定。
运行以下脚本后,我的第一个标签不会随滑块一起旋转。
<?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="DataBinding.MyPage" Title="Slider Bindings Page">
<StackLayout>
<Label Text="ROTATION"
BindingContext="{x:Reference Name=slider}"
Rotation="{Binding Path=Value}"
Font="Bold, Large"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Slider x:Name="slider"
Maximum="360"
VerticalOptions="CenterAndExpand" />
<Label BindingContext="{x:Reference slider}"
Text="{Binding Value,
StringFormat='The angle is {0:F0} degrees'}"
Font="Large"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>
【问题讨论】:
-
试试 Rotation="{绑定值}"
-
我刚刚在所有 3 个平台上运行了该示例,它运行良好,即使在 iOS 上也是如此。您是想在自己的新项目中复制它吗?还是只是将其作为现有示例解决方案的一部分运行?
-
您使用的是哪个版本的 Xamarin.Forms?
-
我认为您可能正在使用旧版本,因为它曾经要求任何引用的控件必须在使用引用之前出现在标记中。看起来在最新版本 1.2.3.6257 上,他们现在已经修复了 xaml 页面,因此控件现在可以引用任何位置。我会把这个写下来作为答案。
-
这很奇怪,因为它应该和我的示例版本一样工作,尤其是当我们使用相同的标记时?你可以通过电子邮件发送项目,我会看看吗?您的经验表明以前的版本总是这样工作的。
标签: xaml xamarin xamarin.forms