- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用一个包含 MvxSpinner 的 MvxListView。当我的应用程序运行时,跟踪显示以下几个实例:
当前微调器 SelectedItem 绑定(bind)中不允许使用空值
我知道数据对象上的条目不为空。这是相关代码:MvxListView 的布局是
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<MvxListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxBind="ItemsSource ShipmentLots.Lots"
local:MvxItemTemplate="@layout/inventorylotview" />
<ImageButton
android:src="@drawable/ic_action_new"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_gravity="center"
local:MvxBind="Click NewLot_Clicked"
android:id="@+id/btnLotNew" />
</LinearLayout>
MvxItemTemplate 的布局如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<MvxSpinner
android:layout_width="130dp"
android:layout_height="match_parent"
android:layout_gravity="center"
style="@style/InputSpinner"
local:MvxItemTemplate="@layout/itemspinner"
local:MvxDropDownItemTemplate="@layout/itemspinnerdropdown"
local:MvxBind="ItemsSource LotColors; SelectedItem LotColor"
android:id="@+id/spinner1" />
<EditText
android:layout_width="150dp"
android:layout_height="wrap_content"
style="@style/InputEditText"
local:MvxBind="Text LotNo" />
<ImageButton
android:src="@drawable/ic_action_delete"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_gravity="center"
local:MvxBind="Click DeleteClicked"
android:id="@+id/btnLotDelete" />
</LinearLayout>
InventoryViewModel 如下:
public class InventoryViewModel
: MvxViewModel
{
public async void Init(Guid ID)
{
await MPS_Mobile_Driver.Droid.DataModel.ShipmentDataSource.GetShipmentInventory(ID);
ShipmentInventory = ShipmentDataSource.CurrInventory;
Shipment = await MPS_Mobile_Driver.Droid.DataModel.ShipmentDataSource.GetShipment((int)ShipmentInventory.idno, (short)ShipmentInventory.idsub);
ShipmentLots = await MPS_Mobile_Driver.Droid.DataModel.ShipmentDataSource.GetShipmentLotList(Shipment.idno, Shipment.idsub);
}
private Shipment _Shipment;
public Shipment Shipment
{
get { return _Shipment; }
set { _Shipment = value; RaisePropertyChanged(() => Shipment); }
}
private ShipmentInventory _ShipmentInventory;
public ShipmentInventory ShipmentInventory
{
get { return _ShipmentInventory; }
set { _ShipmentInventory = value; RaisePropertyChanged(() => ShipmentInventory); }
}
private ShipmentLotList _ShipmentLots;
public ShipmentLotList ShipmentLots
{
get { return _ShipmentLots; }
set { _ShipmentLots = value; RaisePropertyChanged(() => ShipmentLots); }
}
public IMvxCommand NewLot_Clicked
{
get
{
return new MvxCommand(() => NewLot());
}
}
private void NewLot()
{
ShipmentLot Lot = new ShipmentLot();
Lot.ID = Guid.NewGuid();
Lot.idno = Shipment.idno;
Lot.idsub = Shipment.idsub;
ShipmentLots.Lots.Add(Lot);
}
}
ShipmentLots 的 View 模型包含一个名为 Lots 的 ShipmentLot 类型的可观察集合。 ShipmentLots 的类是从 WCF 服务创建的。我将其扩展如下:
public partial class ShipmentLot
{
private static string[] _LotColors = { "Yellow", "Brown", "White", "Blue", "Orange", "Red", "Green", "Purple" };
public string[] LotColors
{
get { return _LotColors; }
}
public IMvxCommand DeleteClicked
{
get
{
return new MvxCommand(() => DeleteLot());
}
}
private void DeleteLot()
{
MPS_Mobile_Driver.Droid.Views.InventoryView act = (MiscFunctions.CurrActivity as MPS_Mobile_Driver.Droid.Views.InventoryView) ?? null;
if (act != null)
{
act.DeleteLot(this);
}
}
}
这负责让删除按钮起作用并为 MvxSpinner 提供颜色列表。当我运行该应用程序时,出现 Null value not allowed 错误,并且 MvxListView 中的第一项在 MvxSpinner 上的颜色错误。随后的工作正常。我不确定第一个有什么不同。有人对此有任何想法吗?
谢谢,吉姆
最佳答案
在@Cheesebaron 和@Stuart 的帮助下,我发现如果您在 MvxItemList 内的 ItemTemplate 中使用 MvxSpinner 或 MvxAutoComplete,那么上面层次结构中的任何内容(包括 MvxItemlist)都不能有 android:layout_height="wrap_content"。原因是如果 Android 操作系统必须动态确定它们的高度,它就必须不止一次地绘制东西。所有的重绘都会让绑定(bind)变得困惑。如果将所有内容都设置为固定高度,则一切正常。要解决上述问题,上面 MvxItemView 的标记应该是
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<MvxListView
android:layout_width="fill_parent"
android:layout_height="300dp"
local:MvxBind="ItemsSource ShipmentLots.Lots"
local:MvxItemTemplate="@layout/inventorylotview" />
<ImageButton
android:src="@drawable/ic_action_new"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
local:MvxBind="Click NewLot_Clicked"
android:id="@+id/btnLotNew" />
</LinearLayout>
关键似乎是安排您的标记,这样它就不必预先呈现 MvxItemList 来确定屏幕部分的高度。想看更多的可以引用这个:
https://github.com/MvvmCross/MvvmCross/issues/944
我还有一个工作示例,说明如何在 MvxItemList 中执行 MvxSpinner:
https://github.com/JimWilcox3/MvxSpinnerTest
这开始是为了演示错误的 repo 协议(protocol)。一旦@Cheesebaron 告诉我出了什么问题,我就更正了它,所以它是一个有效的例子。希望这会对某人有所帮助。
关于c# - 带有 MvxSpinner 的 MvxListView 在第一个项目上显示空条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29133382/
我有一个 MvvmCross MvxSpinner在 Android 中绑定(bind)。用户选择一个值并反射(reflect)在我的属性 MealTypeSelected . 微调器允许用户选择膳
所以我需要更改 MvxSpinner 的文本颜色。我看到您无法更改 xaml 代码的颜色,所以我不得不为微调器使用模板。但是在我为微调器使用模板之前,一切都会与 viewModel 正确绑定(bind
我有一个绑定(bind)到 List 的 MvxSpinner因此: SelectedPhotoCategory SelectedItem 绑定(bind)到的也是一个 PhotoCategory
我正在使用一个包含 MvxSpinner 的 MvxListView。当我的应用程序运行时,跟踪显示以下几个实例: 当前微调器 SelectedItem 绑定(bind)中不允许使用空值 我知道数据对
我正在构建一个涉及从列表中添加项目的表单,但是向用户显示的列表取决于从另一个列表中进行的选择。为此,我有两个 MvxSpinner,每个都有一个绑定(bind)的 ItemsSource 和 Sele
我现在在 Android 上遇到了 Spinner (MvxSpinner) 的问题(但后来我也需要在 iOS 上使用它)。我有本周、上周、本月等微调周期过滤器。我的 api 服务需要这个过滤器来获取
我使用 MvxSpinner 在 MvvmCross for Xamarin 应用程序的组合框中显示国家/地区电话前缀。我可以正确地绑定(bind)到 ItemsSource 属性,所以我可以看到我的
我有一个如下定义的 MvxSpinner,当用户通过 ItemSelected 绑定(bind)在微调器中选择一个项目时,我试图触发一个命令: 我已经确认可以通过添加一个按钮从 View 中
我有一个自定义绑定(bind)的 MvxSpinner,它与我的 Android 和 iOS 应用程序之间共享的 ViewModel 配合得很好。在 Android API 级别 15 (4.0.3)
将 Xamarin.Android 与 MVVMCross 结合使用。当从 MVXSpinner 中选择未绑定(bind)到模型中的 SelectedYear 属性的值时。当加载页面调试器进入 Sel
我是一名优秀的程序员,十分优秀!