C# Xamarin.表格日历

C# Xamarin.表格日历,c#,xamarin,mvvm,view,xamarin.forms,C#,Xamarin,Mvvm,View,Xamarin.forms,我试图在Xamarin.Forms应用程序(MVVM)中显示日历视图。我有这样做的函数,它是在一个名为“Calendar_vm.cs”的ViewModel类中定义的。其定义如下: public Calendar_vm(string email, string password) { Email = email; Password = password; this._user_profiles = new UserProfi

我试图在Xamarin.Forms应用程序(MVVM)中显示日历视图。我有这样做的函数,它是在一个名为“Calendar_vm.cs”的ViewModel类中定义的。其定义如下:

public Calendar_vm(string email, string password)
{
            Email = email;
            Password = password;

            this._user_profiles = new UserProfile_vm(Email, Password);

            SfCalendar calendar = new SfCalendar();
            List<DateTime> black_dates = new List<DateTime>();

            for (int i = 0; i < 5; i++)
            {
                DateTime date = new DateTime(2018, 4, 1 + i);
                black_dates.Add(date);
            }

            calendar.BlackoutDates = black_dates;


            this.Content = calendar;
}  
我知道为什么会出现这个错误,因为我无法直接访问视图(因为MVVM模型)

除了这条线还有别的选择吗


*注意-我不想在Xaml中执行此操作,只需.cs

您需要在视图(contentpage)中创建日历,而不是在viewmodel中创建日历我知道如何通过这样做使其工作,但我需要将其放在我的viewmodel中,由于我将此日历作为登录用户的专用日历,并将从那里编写代码来操作日历。您需要分离您的顾虑。操纵viewmodel中的用户信息,使用绑定(或使用消息传递将需要保存日历的信息发送到视图)。Viewmodel不是操纵图形控件的地方。
'Calendar_vm' does not contain a definition for 'Content' and no extension method 'Content' accepting a first argument of type 'Calendar_vm' could be found ...