Skip to content

Commit

Permalink
Add FontFamily Property
Browse files Browse the repository at this point in the history
sven-s committed Mar 28, 2024
1 parent 4ecc850 commit 6259a26
Showing 2 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Maui.NullableDateTimePicker.Samples.Net8/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -31,7 +31,8 @@
HorizontalOptions="Start"
CornerRadius="5"
Padding="5,0,5,0"
Is12HourFormat="{Binding Is12HourFormat}" />
Is12HourFormat="{Binding Is12HourFormat}"
TextColor="Red"/>

<Button
x:Name="CounterBtn"
24 changes: 21 additions & 3 deletions Maui.NullableDateTimePicker/NullableDateTimePicker.cs
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ public NullableDateTimePicker()
BackgroundColor = Colors.Transparent,
FontSize = this.FontSize,
TextColor = this.TextColor,
FontFamily = FontFamily,
HorizontalOptions = LayoutOptions.Fill,
VerticalOptions = LayoutOptions.Fill,
HorizontalTextAlignment = TextAlignment.Start,
@@ -62,9 +63,6 @@ public NullableDateTimePicker()
VerticalOptions = LayoutOptions.Center
};




_dateTimePickerGrid.SetColumn(_dateTimePickerEntry, 0);
_dateTimePickerGrid.Add(_dateTimePickerEntry);

@@ -668,6 +666,26 @@ public Color TextColor
set { SetValue(TextColorProperty, value); }
}

public static readonly BindableProperty FontFamilyProperty = BindableProperty.Create(
nameof(FontFamily),
typeof(string),
typeof(NullableDateTimePicker),
defaultValue: "Arial",
defaultBindingMode: BindingMode.OneWay,
propertyChanged: (bindable, oldValue, newValue) =>
{
if (bindable is NullableDateTimePicker nullableDateTimePickerBindable && newValue is string fontFamily)
{
nullableDateTimePickerBindable._dateTimePickerEntry.FontFamily = fontFamily;
}
});

public string FontFamily
{
get { return (string)GetValue(FontFamilyProperty); }
set { SetValue(FontFamilyProperty, value); }
}

public new static readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(
nameof(BackgroundColor),
typeof(Color),

0 comments on commit 6259a26

Please sign in to comment.