2

Does anyone have a sample how to use ActionBarSherlock with latest MVVMCross?

There's Roosmaa / MvvmCross.ActionBarSherlock but it doesn't work with latest MVVMCross and I am not sure how ready it is for production use.

There's also LegacyBar but also I couldn't find a sample with MVVMCross.

WriteEatSleepRepeat
  • 3,083
  • 3
  • 33
  • 56

1 Answers1

5

I believe LegacyBar has been used with MvvmCross - so that certainly could be an option for you.

Alternatively, another available option is to add data-binding support to the activities and/or fragments in Sherlock.

For activities, MvvmCross adapts activities into data-binding using a couple of small layers of code to add:

  1. lifecyle events
  2. a data-binding context

This code is described in MVVMCross for android - how to do binding in code?

If you follow the two steps from the 'Additionally' section in that question, then that should enable you to create an MvxSherlockActivity


For fragments, there's no detailed existing answer here on SO, but the process is basically the same two steps with:

  1. an event layer like - https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Droid.Fragging/Fragments/EventSource/MvxEventSourceFragment.cs
  2. a data-binding layer like - https://github.com/slodge/MvvmCross/blob/v3/Cirrious/Cirrious.MvvmCross.Droid.Fragging/Fragments/MvxFragment.cs

This same code should allow someone to create an MvxFooFragment from any FooFragment

Community
  • 1
  • 1
Stuart
  • 66,722
  • 7
  • 114
  • 165
  • 1
    This is great - you literally use that code, and replace fragmentactivity with sherlockactivity and it works! easy – benpage Jul 30 '13 at 00:59
  • 2
    in case anyone is interested, you can also utilise the MvvmCross.Dialog with ABS, you just need to do as above but instead of inheriting from SherlockActivity, you need to create a new class (i called it SherlockDialogActivity) and inherit from sherlocklistactivity, and copy the source code from dialogactivity – benpage Jul 30 '13 at 23:59
  • 1
    @benpage all sounds excellent - please do blog and or gist.github.com share it :) – Stuart Jul 31 '13 at 03:14