Xamarin形式:如何在XamForms.Controls.Calendar中添加事件? [英] Xamarin forms: How to add events in `XamForms.Controls.Calendar`?

查看:37
本文介绍了Xamarin形式:如何在XamForms.Controls.Calendar中添加事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 XamForms.Controls.Calendar 在我的应用程序中显示日历,我已经在所有平台中添加了此软件包.

在xaml中添加了以下代码:

 < StackLayout><控件:日历Horizo​​ntalOptions ="FillAndExpand"VerticalOptions ="CenterAndExpand"x:Name =日历"DateClicked ="CurrentDate"/></StackLayout> 

在c#中:

  XamForms.Controls.Calendar日历=新的XamForms.Controls.Calendar(){WidthRequest = 300,HeightRequest = 300};}公共异步void CurrentDate(Object sender,EventArgs args){var dateSelect = calendar.SelectedDate;} 

我需要为日历中的日期添加活动,例如上课日,学校人数或考试(请参见下面添加的屏幕截图).可以在 XamForms.Controls.Calendar 中使用吗?

解决方案

此插件可以添加特殊日期:

您想要这种效果吗?

I am using XamForms.Controls.Calendar for showing calendar in my application, I have added this package in all platforms.

Added following codes in xaml:

<StackLayout>
        <controls:Calendar  
            HorizontalOptions="FillAndExpand" 
            VerticalOptions="CenterAndExpand"  
            x:Name="calendar" 
            DateClicked="CurrentDate"/>
    </StackLayout>

In 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;
        }

I need to add events for dates in the calendar like school day, school mass or exam(Please see the screenshot added below). Is this possible in XamForms.Controls.Calendar?

解决方案

This plugin can add special dates: 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},
            }
        }
    }
};

Is this effect what you want?

这篇关于Xamarin形式:如何在XamForms.Controls.Calendar中添加事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆