我想为活动设置自定义标题栏,标题栏有一个按钮绑定到活动视图模型中的命令。
不知何故,我并不惊讶它没有工作。
有可能让它工作吗?
编码:
主视图.cs:
[Activity]
public class MainView : MvxActivity
{
protected override void OnCreate (Bundle savedInstanceState)
{
this.RequestWindowFeature(WindowFeatures.CustomTitle);
base.OnCreate (savedInstanceState);
this.Window.SetFeatureInt(WindowFeatures.CustomTitle, Resource.Layout.MainWindowTitle);
SetContentView(Resource.Layout.MainView);
}
}
MainWindowTitle.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">
<ImageButton
android:id="@+id/search"
android:src="@drawable/magnify"
local:MvxBind="Click SearchCommand" />
</LinearLayout>
主视图模型.cs
public class MainViewModel : MvxViewModel
{
public IMvxCommand SearchCommand { get; private set; }
....
}