- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我刚刚开始我的第一个 Xamarin 应用程序,并且已经设置了与新解决方案的默认配置非常相似的东西,更改非常少。
应用程序可以正常编译并部署到虚拟设备。
MvxBindingAttributes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MvxBinding">
<attr name="MvxBind" format="string"/>
<attr name="MvxLang" format="string"/>
</declare-styleable>
<declare-styleable name="MvxControl">
<attr name="MvxTemplate" format="string"/>
</declare-styleable>
<declare-styleable name="MvxListView">
<attr name="MvxItemTemplate" format="string"/>
<attr name="MvxDropDownItemTemplate" format="string"/>
</declare-styleable>
<item type="id" name="MvxBindingTagUnique"/>
<declare-styleable name="MvxImageView">
<attr name="MvxSource" format="string"/>
</declare-styleable>
</resources>
HomeViewModel.cs
public class HomeViewModel : MvxViewModel
{
/// <summary>
/// The _hello.
/// </summary>
private string _hello = "Hello MvvmCross";
/// <summary>
/// Gets or sets the hello.
/// </summary>
public string Hello
{
get
{
return _hello;
}
set
{
_hello = value;
RaisePropertyChanged(() => Hello);
}
}
}
App.cs
public class App : Cirrious.MvvmCross.ViewModels.MvxApplication
{
/// <summary>
/// The initialize.
/// </summary>
public override void Initialize()
{
CreatableTypes().EndingWith("Service").AsInterfaces().RegisterAsLazySingleton();
RegisterAppStart<HomeViewModel>();
}
}
HomeView.cs
[Activity(Label = "View for HomeViewModel")]
public class HomeView : MvxActivity
{
/// <summary> The on create. </summary>
/// <param name="bundle"> The bundle. </param>
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.HomeView);
}
}
HomeView.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
local:MvxBind="Text Hello" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
local:MvxBind="Hello" />
</LinearLayout>
当我在设备上运行它时,Hello MvvmCross
文本按预期显示,但在输出窗口中我看到此错误:
MvxBind:Warning: 8.57 Failed to create target binding for binding Hello for -empty-
[0:] MvxBind:Warning: 8.57 Failed to create target binding for binding Hello for -empty-
05-13 12:56:37.654 I/mono-stdout( 683): MvxBind:Warning: 8.57 Failed to create target binding for binding Hello for -empty-
如果我关闭虚拟设备上的应用程序然后再次启动它,我会得到:
MvxBind:Warning: 97.69 Failed to create target binding for binding Hello for -empty-
[0:] MvxBind:Warning: 97.69 Failed to create target binding for binding Hello for -empty-
05-13 12:58:06.802 I/mono-stdout( 683): MvxBind:Warning: 97.69 Failed to create target binding for binding Hello for -empty-
我似乎找不到比去年更新的关于这个问题的任何信息。
为什么它报告绑定(bind)失败但仍按预期绑定(bind)?另外,为什么警告编号 (8.57/9.69) 会更改但错误消息相同?
解决方案中还包含默认的 LinkerPleaseInclude.cs
文件,所以我现在对此有点困惑。
最佳答案
原来我的一个绑定(bind)声明是不正确的:
HomeView.axml
<TextView
...
local:MvxBind="Hello" />
应该是:
<TextView
...
local:MvxBind="Text Hello" />
Text
类型丢失。
关于c# - MvvmCross-MvxBind :Warning Failed to create target binding for binding Hello for -empty-,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30216024/
我在将 Android.Support.V7.Widget.SwitchCompat 绑定(bind)到我的 View 模型时遇到了麻烦(Mvvmcross 是我正在使用的框架)我做了与在另一个对象上
我找不到可用的所有类型的 Binder 列表,最近一位同事发现了 local:MvxBind="Visibility Property",这对我们的代码有很大帮助。我相信 MvvMCross 有很多我
我使用 Android 的官方 FloatingActionButton。我的问题是绑定(bind)不起作用。在我的例子中,点击事件 (local:MvxBind="Click GoToSharePa
我正在尝试更改 RecyclerView 的项目颜色。下面的代码仅显示了项目布局的根布局 RelativeLayout。 我有以下代码: (项目)布局: ... View 模型: public
在我的 Android MvvmCross 应用程序中,我的 ToggleButton 绑定(bind)在调试构建中表现出色,但在发布时却失败了。 我的 ToggleButton 和绑定(bind)定
我在 Xamarin 中遇到 Android 应用程序问题。我有 MenuCardView.axml,其中 MvxGridView 和 ItemSource 但我不想在这里使用 ItemClick。我
如何使用 bool 值的组合来设置 MvxBind 按钮上的 enabled 属性? 例如: 使用一个 bool 值,通过以下方式实现绑定(bind): 但是我该如何使用多个 bool 值来实现呢?
我有一个小问题: 在我的 axml 设计器中,我有这样的东西: 这很好用,但我怎么能组合/连接 2 个属性(或更多).. 所以类似于:FirstName + SecondName(一个文本中有 2
嘿,我是 MvvmCross 初学者,我尝试重现 this在我自己的示例应用程序中,但我遇到了一些奇怪的构建错误: 错误 3 属性“MvxBind”已定义 错误 4 属性“MvxLang”已定义 错误
解决方案之前运行良好,直到我将菜单添加到应用程序并构建,它给了我上述错误。我的代码如下: 有什么解决办法吗?我努力了 1) xmlns:local="http://sche
我正在尝试使用提供的代码创建一个简单的服务,但我不明白为什么在绑定(bind)时会出现异常。 10-19 11:42:09.148 I/mono-stdout(1622):MvxBind:Error:
我有一个包含 LocationViewModel 的 ObservableCollection 的 ViewModel。这些在网格中显示为图 block 。每个 LocationViewModel 都
使用 MvxBind 绑定(bind)到 ViewModel 属性的常用 MvvmCross 语法android 布局文件中的属性如下所示: 所以访问ViewModel.ViewModelPrope
我刚刚开始我的第一个 Xamarin 应用程序,并且已经设置了与新解决方案的默认配置非常相似的东西,更改非常少。 应用程序可以正常编译并部署到虚拟设备。 MvxBindingAttributes.xm
我是一名优秀的程序员,十分优秀!