我的观点是Xamarin Android自定义标题

时间:2014-11-26 17:29:07

标签: c# android xamarin viewmodel mvvmcross

您好我想设置我的标题视图以匹配当前文章标题。

我尝试了但是我得到了一个null异常,因为ViewModel在View之前没有加载

ArticleView.cs

protected override void OnCreate(Bundle bundle)
{
   base.OnCreate(bundle);

   SetContentView(Resource.Layout.ArticleView);

   var vm = this.ViewModel as ArticleViewModel;
   this.Title = vm.CurrentArticle.Name;
}

我从MvxGridView

导航到文章
<MvxGridView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/listitemarticles1"
    android:numColumns="2"
    android:verticalSpacing="2dp"
    android:horizontalSpacing="2dp"
    local:MvxBind="ItemsSource ArticlesCollection;ItemClick ShowArticleCommand"
    local:MvxItemTemplate="@layout/articletemplate" />

编辑:

更改删除我的操作栏是一个好方法主题=&#34; @android:style / Theme.Holo.Light.DarkActionBar&#34; to Theme =&#34; @android:style / Theme.Holo.Light.NoActionBar&#34;并在axml中创建我的操作栏,我可以在其中设置文本绑定到CurrentArticle.Name?

0 个答案:

没有答案