は、私はまだMvvmCrossとiOSのカレンダーコントロールを使用していないが、私はあなたのAndroidの実装と何のViewModelが見えるように必要を与えることができ、かつ配線までのiOS制御することはあまりにも難しいことではありません。
のViewModel:
DateTime _gameStartDate;
public DateTime GameStartDate
{
get { return _gameStartDate; }
set { SetProperty(ref _gameStartDate, value); }
}
アンドロイド活動:
Button _button;
DatePickerFragment _datePicker;
protected override void OnCreate(Bundle bundle)
{
_button = FindViewById<Button>(Resource.Id.your_button_id);
_button.Click += Button_OnClick;
}
void Button_OnClick(object sender, EventArgs eventArgs)
{
_datePicker = DatePickerFragment.NewInstance(delegate (DateTime date)
{
ViewModel.GameStartDate = date;
});
_datePicker.Show(FragmentManager, DatePickerFragment.TAG);
}
DatePickerFragment.cs:
public class DatePickerFragment : DialogFragment, IOnDateSetListener
{
public static readonly string TAG = "X:" + typeof(DatePickerFragment).Name.ToUpper();
Action<DateTime> _dateSelectedHandler = delegate { };
public static DatePickerFragment NewInstance(Action<DateTime> onDateSelected)
{
var frag = new DatePickerFragment
{
_dateSelectedHandler = onDateSelected
};
return frag;
}
public override Dialog OnCreateDialog(Bundle savedInstanceState)
{
var currentDate = DateTime.Now;
var dialog = new DatePickerDialog(Activity, this, currentDate.Year, currentDate.Month - 1, currentDate.Day);
return dialog;
}
public void OnDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
{
var selectedDate = new DateTime(year, monthOfYear + 1, dayOfMonth);
_dateSelectedHandler?.Invoke(selectedDate);
}
}