MvvmCross plugin for interacting with the user from a view model. ##Features
- Alert - simple alert to the user, async or optional callback when done
- Confirm - dialog with ok/cancel, async or callback with button clicked or just when ok clicked
- Input - asks user for input with ok/cancel, async or callback with button clicked and data or just data when ok clicked
##Usage ####Alert Async
public ICommand SubmitCommand
{
get
{
return new MvxCommand(async () =>
{
if (string.IsNullOrEmpty(FirstName))
{
await Mvx.Resolve<IUserInteraction>().AlertAsync("First Name is Required");
return;
}
//do work
});
}
}
####Alert callback
public ICommand SubmitCommand
{
get
{
return new MvxCommand(() =>
{
if (string.IsNullOrEmpty(FirstName))
{
Mvx.Resolve<IUserInteraction>().Alert("First Name is Required");
return;
}
//do work
});
}
}
####Confirm/Input Async
public ICommand SubmitCommand
{
get
{
return new MvxCommand(async () =>
{
if (await Mvx.Resolve<IUserInteraction>().ConfirmAsync("Are you sure?"))
{
//do work
}
});
}
}
####Confirm/Input callback
public ICommand SubmitCommand
{
get
{
return new MvxCommand(() =>
{
Mvx.Resolve<IUserInteraction>().Confirm("Are you sure?", async () =>
{
//Do work
});
});
}
}
##Adding to your project
- Follow stuarts directions (step 3) - http://slodge.blogspot.com/2012/10/build-new-plugin-for-mvvmcrosss.html
- Grab the UserInteractionPluginBootstrap file from appropriate Droid/Touch folder. Drop into your project in the Bootstrap folder, change the namespace.
I will be working on a nuget package as time permits.