I've seen Xamarin recently released as component http://components.xamarin.com/view/xamandroidsupportv7appcompat
I would like to use it with MvvmCross in my app, but I ran into difficulties, so I turned to google and found thistutorial http://blog.ostebaronen.dk/2013/11/getting-support-v7-working-with.html
I don't understand how to use it correctly with MvvmCross though. How can I bind buttons in it to ICommands etc. ? Can I specify whole actionbar as ViewModel and bind to it ? If so, how ?
There is no way to bind ActionBar to ICommands with MvvmCross. But you can use a simple trick and call into your ICommands from the activity when a button on ActionBar is pressed.
public override bool OnCreateOptionsMenu(IMenu menu)
{
this.MenuInflater.Inflate(Resource.Menu.QuoteDetails, menu);
m_MenuItem_EditQuote = menu.FindItem(Resource.Id.menu_EditQuote);
m_MenuItem_EditQuote.SetVisible(ViewModel.CanEdit);
return true;
}
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Resource.Id.menu_EditQuote:
ViewModel.EditQuoteCommand.Execute(null);
return true;
case Resource.Id.menu_ViewQuote:
ViewModel.DownloadQuoteCommand.Execute(null);
return true;
case Resource.Id.menu_EmailQuote:
ViewModel.EmailQuoteCommand.Execute(null);
return true;
default:
return base.OnOptionsItemSelected(item);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With