ME-MarvinE / XCalendar

A plugin for .NET providing an API for representing a calendar along with fully customisable calendar controls for Xamarin Forms and .NET MAUI
MIT License
300 stars 36 forks source link

Set localize manual #165

Closed nhhoangit closed 1 year ago

nhhoangit commented 1 year ago

I'd like to set localize for navigation and DayOfWeek manually. It's seem not implement this feature.

ME-MarvinE commented 1 year ago

Issue #29 asks the same thing about localizing days of week. You will be able to find a solution/answer in the comments. In short, the CalendarView's DayNameTemplate property can be used to manually implement translations for the days of the week.

For navigation, the CalendarView's NavigationTemplate property can be used and a NavigationView control is provided which includes all the properties of a Label.

Discussion #121 may also be helpful.

nhhoangit commented 1 year ago

Issue #29 can be resolved with custom xml below. Thanks

<xc:CalendarView.DayNameTemplate>
    <DataTemplate>
        <Label HorizontalTextAlignment="Center" x:DataType="{x:Type System:DayOfWeek}"  Text="{Binding .,Converter={StaticResource XCalendarDayConverter}}"/>
    </DataTemplate>
</xc:CalendarView.DayNameTemplate>

Need verify if (value != null) in Converter otherwise it ignore code below.