Xamarin 表单:如何在“XamForms.Controls.Calendar”中添加事件?
Xamarin forms: How to add events in `XamForms.Controls.Calendar`?
我正在使用 XamForms.Controls.Calendar
在我的应用程序中显示日历,我已经在所有平台中添加了这个包。
在 xaml 中添加了以下代码:
<StackLayout>
<controls:Calendar
HorizontalOptions="FillAndExpand"
VerticalOptions="CenterAndExpand"
x:Name="calendar"
DateClicked="CurrentDate"/>
</StackLayout>
在 C# 中:
XamForms.Controls.Calendar calendar = new XamForms.Controls.Calendar()
{
WidthRequest = 300,
HeightRequest = 300
};
}
public async void CurrentDate(Object sender, EventArgs args)
{
var dateSelect = calendar.SelectedDate;
}
我需要为日历中的日期添加活动,例如上学日、学校弥撒或考试(请参阅下面添加的屏幕截图)。这在 XamForms.Controls.Calendar
中可行吗?
此插件可以添加特殊日期:https://github.com/rebeccaXam/XamForms.Controls.Calendar/wiki/SpecialDates
calendar.SpecialDates = new List<SpecialDate>
{
new SpecialDate(DateTime.Now.AddDays(3))
{
Selectable = true,
BackgroundPattern = new BackgroundPattern(1)
{
Pattern = new List<Pattern>
{
new Pattern { WidthPercent = 1f, HightPercent = 0.6f, Color = Color.Transparent },
new Pattern{ WidthPercent = 1f, HightPercent = 0.4f, Color = Color.Transparent, Text = "Mass", TextColor=Color.Black, TextSize=11, TextAlign=TextAlign.Middle},
}
}
}
};
这个效果是你想要的吗?
我正在使用 XamForms.Controls.Calendar
在我的应用程序中显示日历,我已经在所有平台中添加了这个包。
在 xaml 中添加了以下代码:
<StackLayout>
<controls:Calendar
HorizontalOptions="FillAndExpand"
VerticalOptions="CenterAndExpand"
x:Name="calendar"
DateClicked="CurrentDate"/>
</StackLayout>
在 C# 中:
XamForms.Controls.Calendar calendar = new XamForms.Controls.Calendar()
{
WidthRequest = 300,
HeightRequest = 300
};
}
public async void CurrentDate(Object sender, EventArgs args)
{
var dateSelect = calendar.SelectedDate;
}
我需要为日历中的日期添加活动,例如上学日、学校弥撒或考试(请参阅下面添加的屏幕截图)。这在 XamForms.Controls.Calendar
中可行吗?
此插件可以添加特殊日期:https://github.com/rebeccaXam/XamForms.Controls.Calendar/wiki/SpecialDates
calendar.SpecialDates = new List<SpecialDate>
{
new SpecialDate(DateTime.Now.AddDays(3))
{
Selectable = true,
BackgroundPattern = new BackgroundPattern(1)
{
Pattern = new List<Pattern>
{
new Pattern { WidthPercent = 1f, HightPercent = 0.6f, Color = Color.Transparent },
new Pattern{ WidthPercent = 1f, HightPercent = 0.4f, Color = Color.Transparent, Text = "Mass", TextColor=Color.Black, TextSize=11, TextAlign=TextAlign.Middle},
}
}
}
};
这个效果是你想要的吗?