xamarin mvvm交叉绑定相对布局
xamarin mvvmcross binding relative layout
我是 mvvmcross 的新手。我不知道如何将相对布局的触摸事件绑定到视图模型。有人可以帮我解决这个问题吗?提前致谢。
这可以使用标准的 MvvmCross 代码实现。对于视图模型,您可以使用类似的东西:
public class SomeViewModel : MvxViewModel
{
public IMvxCommand OpenSomethingCommand { get; private set; }
public SomeViewModel ()
{
OpenSomethingCommand = new MvxCommand(() => ShowViewModel<SomeOtherNewViewModel>());
}
}
那么对于你的android项目中的布局,你可以使用:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
local:MvxBind="Click OpenSomethingCommand"
android:id="@+id/someLayout">
//Wrap any other layouts in here
</RelativeLayout>
我是 mvvmcross 的新手。我不知道如何将相对布局的触摸事件绑定到视图模型。有人可以帮我解决这个问题吗?提前致谢。
这可以使用标准的 MvvmCross 代码实现。对于视图模型,您可以使用类似的东西:
public class SomeViewModel : MvxViewModel
{
public IMvxCommand OpenSomethingCommand { get; private set; }
public SomeViewModel ()
{
OpenSomethingCommand = new MvxCommand(() => ShowViewModel<SomeOtherNewViewModel>());
}
}
那么对于你的android项目中的布局,你可以使用:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
local:MvxBind="Click OpenSomethingCommand"
android:id="@+id/someLayout">
//Wrap any other layouts in here
</RelativeLayout>