我正在制作一个页面,其中包含一个ViewPager
包含TextView
显示标题和ListView
显示我制作的自定义视图中的一些图表的页面。
我在 WP7 中运行良好,代码如下:
<controls:Pivot Title="Stakeholder">
<controls:PivotItem Header="Last hour">
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Locations}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" HorizontalAlignment="Center" />
<chart:MiniChartHour MinMaxRange="{Binding ChartHourRange}" Data="{Binding ChartHourSamples}" Margin="0,0,0,15" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</controls:PivotItem>
<!--Pivot item last day-->
<controls:PivotItem Header="Last day">
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Locations}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" HorizontalAlignment="Center" />
<chart:MiniChartDay MinMaxRange="{Binding ChartDayRange}" Data="{Binding ChartDaySamples}" Margin="0,0,0,15" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</controls:PivotItem>
...
More of these here
...
</controls:Pivot>
然而,在 WP7 上,它使用了一个Pivot
控件,类似于ViewPager
android 中的控件。该Locations
属性是a ObservableCollection
,它拥有LocationViewModel
s。每个LocationViewModel
s 都有 4 个不同图表的范围和数据,每个图表显示不同的数据粒度。在上面的代码中,这个Locations
属性被绑定了几次,没有任何问题。但是,当我想在 Android 上做类似的事情时,会SwissBindings
不止一次地发出很多关于 Path 的警告。我在 Android 上的 View 代码如下所示:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/BK.EMS.Stakeholder.UI.Droid.vNext"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/chartHeader"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
local:MvxBind="Text Name"
/>
<RelativeLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<Mvx.MvxBindableListView
android:id="@+id/chartListHour"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:cacheColorHint="#00000000"
android:listSelector="#00000000"
android:orientation="vertical"
local:MvxItemTemplate="@layout/chartdetailhour"
local:MvxBind="ItemSource Locations, Visibility IsHourVisible,Converter=Visibility"
/>
<Mvx.MvxBindableListView
android:id="@+id/chartListDay"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:cacheColorHint="#00000000"
android:listSelector="#00000000"
android:orientation="vertical"
local:MvxItemTemplate="@layout/chartdetailday"
local:MvxBind="ItemSource Locations, Visibility IsDayVisible,Converter=Visibility"
/>
...
More of the BindableListViews here
...
</RelativeLayout>
</FrameLayout>
我得到的例外是:
Problem parsing Swiss binding MvxException: You cannot specify Path more than once - first Path 'Locations', second Path 'Visibility IsHourVisible', position 50 in ItemSource Locations, Visibility IsHourVisible,Converter=Visibility
at Cirrious.MvvmCross.Binding.Parse.Binding.Swiss.MvxSwissBindingParser.ParseNextBindingDescriptionOptionInto (Cirrious.MvvmCross.Binding.Interfaces.Parse.MvxSerializableBindingDescription description) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Binding.Parse.Binding.Swiss.MvxSwissBindingParser.ParseBindingDescription () [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Binding.Parse.Binding.Swiss.MvxSwissBindingParser.ParseTargetPropertyNameAndDescription () [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Binding.Parse.Binding.Swiss.MvxSwissBindingParser.TryParseBindingSpecification (System.String text, Cirrious.MvvmCross.Binding.Interfaces.Parse.MvxSerializableBindingSpecification& requestedBindings) [0x00000] in <filename unknown>:0