【发布时间】:2016-01-14 11:23:38
【问题描述】:
我正在尝试将一维字符串数组属性绑定到 TextView,但它不起作用。
视图模型:
public string[] Player
{
get { return _player; }
set { _player = value; RaisePropertyChanged(() => Player); }
}
Windows8 xaml(完美运行):
<TextBox x:Name="txtbox_PlayerName1" Text="{Binding Path=Player[0], Mode=TwoWay}" Grid.Column="2" Width="600" Height="30" HorizontalAlignment="Left"></TextBox>
Android axml:
<TextView
android:layout_marginTop="20dp"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView1"
local:MvxBind="Text Player[0]" />
日志:
MvxBind:Warning:103,21 无法绑定:未找到源属性源 IndexedProperty:0 on String[] 01-14 12:17:26.419 I/mono-stdout(28171): MvxBind:Warning:103,21 Unable to bind: source property source not found IndexedProperty:0 on String[]
我尝试了不同的绑定语法,但没有成功。我还尝试绑定“播放器”对象的字符串属性,例如 Players[0].PlayerName,它在 XAML 中运行良好,但不适用于 Android。
https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ApiExamples/ApiExamples.Droid/Resources/Layout/Test_ObservableCollection.axml 它在 Mvvmcross 的 API 示例中工作(使用 Observable Collection,我尝试了同样的事情但没有成功)
【问题讨论】:
-
我无法重现这个。你什么时候填充你的播放器?
-
在 Init 方法中.. 我还尝试在 ViewModel-constructor 中填充我的 Player 数组,结果相同:/ 它在 MvvmCross 3.5.1 btw 上运行
标签: c# android xamarin mono mvvmcross