From 2c376341de9b66de6895c41b1898da9cb2f3fce5 Mon Sep 17 00:00:00 2001 From: saiganesh-sakthivel Date: Wed, 30 Nov 2022 19:08:38 +0530 Subject: [PATCH] update the README.md file for the KB --- README.md | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 131 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 36c42d1..cfa4ace 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,131 @@ -# custom-font-schedule-xamarin -How to add custom font in Xamarin.Forms Schedule (SfSchedule) +# How to add custom font in Xamarin.Forms Schedule (SfSchedule) + +You can customize the month view with a custom font family by setting the FontFamily property to the following classes in Xamarin.Forms [SfSchedule](https://www.syncfusion.com/xamarin-ui-controls/xamarin-scheduler). +* [ViewHeaderStyle](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfSchedule.XForms.ViewHeaderStyle.html) - You can change the appearance of ViewHeaderStyle by setting the DayFontFamily property of Schedule ViewHeaderStyle. +* [HeaderStyle](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfSchedule.XForms.SfSchedule.html#Syncfusion_SfSchedule_XForms_SfSchedule_HeaderStyle) - You can change the appearance of HeaderStyle by setting the FontFamily property of Schedule HeaderStyle. +* [MonthCellStyle](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfSchedule.XForms.SfSchedule.html#Syncfusion_SfSchedule_XForms_SfSchedule_MonthCellStyle) - You can change the appearance of MonthCellStyle by setting the FontFamily property of Schedule MonthCellStyle. +* [MonthInlineViewStyle](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfSchedule.XForms.MonthInlineViewStyle.html) - You can change the appearance of MonthInlineViewStyle by setting the FontFamily property of Schedule MonthInlineViewStyle. +* [WeekNumberStyle](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfSchedule.XForms.WeekNumberStyle.html) - You can change the appearance of WeekNumber by setting the FontFamily property of Schedule WeekNumberStyle. + +The following steps describe how to add a custom font file in the platform-specific projects. + +**Android** + +Add a custom font file in the Assets folder and set Build Action to AndroidAsset for the font file. + +**iOS** + +**STEP1:** Add a custom font file in the Resources folder and set Build Action to BundleResource. Then, ensure that the copy to output directory is set to AlwaysCopy. + +**STEP2:** Add a custom font file name in the info.plist file as demonstrated in the following code sample. +``` +…… +        UIAppFonts +        +            Lobster-Regular.ttf +        +…… +``` +**UWP** + +Add a custom font file in the Assets folder and set Build Action to Content. + +**XAML** + +Set custom font for schedule month view using font family properties. +``` + +  +    +        +            +                +            +        +    +  +    +        +            +                +            +        +    +  +    +        +            +                +            +        +    +  +    +        +            +                +                    +                        +                    +                +            +        +    +  +    +        +    +  +    +        +    + +``` +**C#** + +FontStyle for month inline view updated in OnMonthInlineLoaded event. +``` +public class SchedulerPageBehavior : Behavior +{ +    private SfSchedule schedule; +    protected override void OnAttachedTo(ContentPage bindable) +    { +        base.OnAttachedTo(bindable); +        this.schedule = bindable.Content.FindByName("Schedule"); +        this.WireEvents(); +    } +  +    private void WireEvents() +    { +        this.schedule.OnMonthInlineLoadedEvent += Schedule_OnMonthInlineLoadedEvent; +    } +  +    private void Schedule_OnMonthInlineLoadedEvent(object sender, MonthInlineLoadedEventArgs args) +    { +        MonthInlineViewStyle monthInlineViewStyle = new MonthInlineViewStyle(); +        monthInlineViewStyle.FontFamily = Device.OnPlatform("Lobster-Regular", "Lobster-Regular.ttf", "Assets/Lobster-Regular.ttf#Lobster"); +        args.monthInlineViewStyle = monthInlineViewStyle; +    } +  +    protected override void OnDetachingFrom(ContentPage bindable) +    { +        base.OnDetachingFrom(bindable); +        this.UnWireEvents(); +    } +  +    private void UnWireEvents() +    { +        this.schedule.OnMonthInlineLoadedEvent += Schedule_OnMonthInlineLoadedEvent; +    } +} +``` + +KB article - [How to add custom font in Xamarin.Forms Schedule (SfSchedule)](https://www.syncfusion.com/kb/12257/how-to-add-custom-font-in-xamarin-forms-schedule-sfschedule) \ No newline at end of file