![](/img/trans.png)
[英]How to handle screen rotation/orientation in Xamarin.Forms/XLabs?
[英]Xamarin XLabs Forms CalendarView not working on Android
我正在Xamarin Studio的XLabs Nuget包中的Xamarin Forms中使用CalendarView控件。
CalendarView的定義如下,但是android設備上未顯示日歷:
using System;
using Xamarin.Forms;
using XLabs.Forms.Controls;
namespace CustomRenderer
{
public class MyPage : ContentPage
{
public MyPage()
{
CalendarView calendarView = new XLabs.Forms.Controls.CalendarView
{
MinDate = new DateTime(2016, 1,1),
MaxDate = new DateTime(2016, 1, 31),
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
ShowNavigationArrows = true,
DateBackgroundColor = Color.White,
IsVisible = true,
};
calendarView.DateSelected += (object sender, DateTime e) => {
};
Content = new StackLayout
{
HeightRequest = 400,
WidthRequest = 320,
Children =
{
calendarView
}
};
}
}
}
記住要使用以下內容初始化MainActivity
MainActivity : XFormsApplicationDroid
並將XLabs也添加到Droid項目中。 現在正在工作。
請使用下面的代碼,它將起作用
var MinDt = new DateTime(1970, 1, 1);
var MaxDt = new DateTime(2070,1,1);
Pages.Add(id, new CarlNavPage(new ContentPage
{
Content = new CalendarView() {
MinDate = CalendarView.FirstDayOfMonth(MinDt),
MaxDate = CalendarView.LastDayOfMonth(MaxDt),
HighlightedDateBackgroundColor = Color.FromRgb(227, 227, 227),
MonthTitleBackgroundColor = Color.FromHex("#f1eff5"),
ShouldHighlightDaysOfWeekLabels = false,
SelectionBackgroundStyle = CalendarView.BackgroundStyle.Fill,
TodayBackgroundStyle = CalendarView.BackgroundStyle.CircleOutline,
BackgroundColor = Color.FromHex("#f1eff5"),
HighlightedDateForegroundColor = Color.FromHex("#f1eff5"),
// HighlightedDaysOfWeek = new DayOfWeek[] { DayOfWeek.Saturday, DayOfWeek.Sunday },
ShowNavigationArrows = true,
},
}));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.