【问题标题】:xamarin mvvmcross binding relative layoutxamarin mvvmcross 绑定相对布局
【发布时间】:2015-07-22 06:41:00
【问题描述】:

我是 mvvmcross 的新手。我不知道如何将相对布局的触摸事件绑定到视图模型。有人可以帮我解决这个问题。提前致谢。

【问题讨论】:

    标签: xamarin xamarin.android mvvmcross


    【解决方案1】:

    这可以使用标准的 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>
    

    【讨论】:

    • 如何为 viewpager 的子布局绑定 onclick 事件?
    猜你喜欢
    • 2014-03-23
    • 2017-01-03
    • 1970-01-01
    • 1970-01-01
    • 2018-01-22
    • 2018-09-05
    • 2020-02-29
    • 2015-10-25
    • 1970-01-01
    相关资源
    最近更新 更多