MvvMCross绑定到&lt;&包括GT;在android系统布局 [英] MvvMCross bind to <include> in android layout
问题描述
是否有可能一个对象 X
绑定到包括标签,这样在包括布局结合上下文是 X
?我想使用一个布局多次,但不是在一个列表中。
MainLayout.xml
...
&LT;包括
机器人:ID =@ + ID / btnDealerMap
机器人:layout_width =64dp
机器人:layout_height =64dp
机器人:知名度=水涨船高
布局=@布局/ ServiceBarButtonPhone
本地:MvxBind =??? X/&GT;
...
ServiceBarButtonPhone.xml
标题
和文本
是 X
属性。
&LT;的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
XMLNS:地方=HTTP://schemas.android.com/apk/res / ...
机器人:layout_width =96dp
机器人:layout_height =96dp&GT;
&LT;的TextView
...
机器人:ID =@ + ID / txtTitle
本地:MvxBind =TEXT标题/&GT;
&LT;的TextView
...
机器人:ID =@ + ID / txtText
本地:MvxBind =TEXT文本/&GT;
&LT; / RelativeLayout的&GT;
有什么可以对外部绑定包含
- 但你可以把正常的结合在里面文件 - 它然后就被在编译时包含英寸见一个例子:<一href=\"https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ApiExamples/ApiExamples.Droid/Resources/Layout/Test_If.axml\" rel=\"nofollow\">https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ApiExamples/ApiExamples.Droid/Resources/Layout/Test_If.axml
相反,如果你想拥有自己的内部布局的DataContext
,试试 MvxView
- 为的例子即见 MvxFrameControl
- 作为在N部分使用= 26 - 见<一href=\"https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/blob/b405eef7dddf4d65b00116e142855653eae9f06b/N-26-Fraggle/Rock.Droid/Resources/Layout/FirstView.axml\" rel=\"nofollow\">https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/blob/b405eef7dddf4d65b00116e142855653eae9f06b/N-26-Fraggle/Rock.Droid/Resources/Layout/FirstView.axml
Is it possible to bind an object X
to the include tag, so that the context of binding in the included layout is X
? I want to use a layout multiple times, but not in a list.
MainLayout.xml
...
<include
android:id="@+id/btnDealerMap"
android:layout_width="64dp"
android:layout_height="64dp"
android:visibility="gone"
layout="@layout/ServiceBarButtonPhone"
local:MvxBind="??? X" />
...
ServiceBarButtonPhone.xml
Title
and Text
are properties of X
.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/..."
android:layout_width="96dp"
android:layout_height="96dp">
<TextView
...
android:id="@+id/txtTitle"
local:MvxBind="Text Title" />
<TextView
...
android:id="@+id/txtText"
local:MvxBind="Text Text" />
</RelativeLayout>
There's nothing to bind on the outside of the include
- but you can put normal binding on the inside of the file - it then just gets included in at compile time. See one example in: https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ApiExamples/ApiExamples.Droid/Resources/Layout/Test_If.axml
If instead you want an inner 'layout' with its own DataContext
, try MvxView
- for an example of that see MvxFrameControl
- as used in part of N=26 - see https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/blob/b405eef7dddf4d65b00116e142855653eae9f06b/N-26-Fraggle/Rock.Droid/Resources/Layout/FirstView.axml
这篇关于MvvMCross绑定到&lt;&包括GT;在android系统布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!