diff --git a/XCalendar.Forms/Views/CalendarView.xaml b/XCalendar.Forms/Views/CalendarView.xaml index b5848f6..622e39e 100644 --- a/XCalendar.Forms/Views/CalendarView.xaml +++ b/XCalendar.Forms/Views/CalendarView.xaml @@ -18,12 +18,12 @@ + RightArrowCommandParameter="{Binding RightArrowCommandParameter, Source={x:Reference CalendarView_Unique}}"/> diff --git a/XCalendar.Forms/Views/NavigationView.xaml.cs b/XCalendar.Forms/Views/NavigationView.xaml.cs index aea8f3b..1b996b1 100644 --- a/XCalendar.Forms/Views/NavigationView.xaml.cs +++ b/XCalendar.Forms/Views/NavigationView.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows.Input; +using System; +using System.Windows.Input; using Xamarin.Forms; using Xamarin.Forms.Xaml; @@ -10,6 +11,11 @@ public partial class NavigationView : ContentView #region Properties #region Bindable Properties + public DateTime? DateTime + { + get { return (DateTime?)GetValue(DateTimeProperty); } + set { SetValue(DateTimeProperty, value); } + } public TextTransform TextTransform { get { return (TextTransform)GetValue(TextTransformProperty); } @@ -123,6 +129,7 @@ public float ArrowCornerRadius } #region Bindable Properties Initialisers + public static readonly BindableProperty DateTimeProperty = BindableProperty.Create(nameof(DateTime), typeof(DateTime?), typeof(DayView), System.DateTime.Today); public static readonly BindableProperty CharacterSpacingProperty = BindableProperty.Create(nameof(CharacterSpacing), typeof(double), typeof(NavigationView), Label.CharacterSpacingProperty.DefaultValue); public static readonly BindableProperty FontAttributesProperty = BindableProperty.Create(nameof(FontAttributes), typeof(FontAttributes), typeof(NavigationView), FontAttributes.Bold); public static readonly BindableProperty FontFamilyProperty = BindableProperty.Create(nameof(FontFamily), typeof(string), typeof(NavigationView), Label.FontFamilyProperty.DefaultValue); @@ -154,6 +161,8 @@ public float ArrowCornerRadius #region Constructors public NavigationView() { + SetBinding(TextProperty, new Binding(path: "DateTime", stringFormat: "{0:MMMM yyy}", source: this)); + InitializeComponent(); } #endregion diff --git a/XCalendar.Maui/Views/CalendarView.xaml b/XCalendar.Maui/Views/CalendarView.xaml index 0db4c12..3606989 100644 --- a/XCalendar.Maui/Views/CalendarView.xaml +++ b/XCalendar.Maui/Views/CalendarView.xaml @@ -15,17 +15,17 @@ False - - + + + RightArrowCommandParameter="{Binding RightArrowCommandParameter, Source={x:Reference CalendarView_Unique}}"/> diff --git a/XCalendar.Maui/Views/NavigationView.xaml.cs b/XCalendar.Maui/Views/NavigationView.xaml.cs index 0f19005..70455a3 100644 --- a/XCalendar.Maui/Views/NavigationView.xaml.cs +++ b/XCalendar.Maui/Views/NavigationView.xaml.cs @@ -8,6 +8,11 @@ public partial class NavigationView : ContentView #region Properties #region Bindable Properties + public DateTime? DateTime + { + get { return (DateTime?)GetValue(DateTimeProperty); } + set { SetValue(DateTimeProperty, value); } + } public TextTransform TextTransform { get { return (TextTransform)GetValue(TextTransformProperty); } @@ -121,6 +126,7 @@ public float ArrowCornerRadius } #region Bindable Properties Initialisers + public static readonly BindableProperty DateTimeProperty = BindableProperty.Create(nameof(DateTime), typeof(DateTime?), typeof(DayView), System.DateTime.Today); public static readonly BindableProperty CharacterSpacingProperty = BindableProperty.Create(nameof(CharacterSpacing), typeof(double), typeof(NavigationView), Label.CharacterSpacingProperty.DefaultValue); public static readonly BindableProperty FontAttributesProperty = BindableProperty.Create(nameof(FontAttributes), typeof(FontAttributes), typeof(NavigationView), FontAttributes.Bold); public static readonly BindableProperty FontFamilyProperty = BindableProperty.Create(nameof(FontFamily), typeof(string), typeof(NavigationView), Label.FontFamilyProperty.DefaultValue); @@ -152,6 +158,8 @@ public float ArrowCornerRadius #region Constructors public NavigationView() { + SetBinding(TextProperty, new Binding(path: "DateTime", stringFormat: "{0:MMMM yyy}", source: this)); + InitializeComponent(); } #endregion diff --git a/XCalendarFormsSample/XCalendarFormsSample/Views/PlaygroundPage.xaml b/XCalendarFormsSample/XCalendarFormsSample/Views/PlaygroundPage.xaml index 3c0ad6b..4f05d40 100644 --- a/XCalendarFormsSample/XCalendarFormsSample/Views/PlaygroundPage.xaml +++ b/XCalendarFormsSample/XCalendarFormsSample/Views/PlaygroundPage.xaml @@ -926,16 +926,16 @@ @@ -944,14 +944,14 @@ ArrowBackgroundColor="{Binding NavigationArrowBackgroundColor}" ArrowColor="{Binding NavigationArrowColor}" BackgroundColor="{Binding NavigationBackgroundColor}" + BindingContext="{Binding BindingContext, Source={RelativeSource TemplatedParent}}" + DateTime="{Binding DateTime, Source={RelativeSource TemplatedParent}}" + HeightRequest="{Binding NavigationHeightRequest}" LeftArrowCommand="{Binding LeftArrowCommand, Source={x:RelativeSource TemplatedParent}}" LeftArrowCommandParameter="{Binding LeftArrowCommandParameter, Source={RelativeSource TemplatedParent}}" - BindingContext="{Binding BindingContext, Source={RelativeSource TemplatedParent}}" RightArrowCommand="{Binding RightArrowCommand, Source={x:RelativeSource TemplatedParent}}" RightArrowCommandParameter="{Binding RightArrowCommandParameter, Source={RelativeSource TemplatedParent}}" - HeightRequest="{Binding NavigationHeightRequest}" Style="{StaticResource DefaultNavigationViewStyle}" - Text="{Binding Text, Source={RelativeSource TemplatedParent}}" TextColor="{Binding NavigationTextColor}"/> diff --git a/XCalendarMauiSample/Views/PlaygroundPage.xaml b/XCalendarMauiSample/Views/PlaygroundPage.xaml index d92b837..bf9e9f4 100644 --- a/XCalendarMauiSample/Views/PlaygroundPage.xaml +++ b/XCalendarMauiSample/Views/PlaygroundPage.xaml @@ -968,16 +968,16 @@ @@ -986,14 +986,14 @@ ArrowBackgroundColor="{Binding NavigationArrowBackgroundColor}" ArrowColor="{Binding NavigationArrowColor}" BackgroundColor="{Binding NavigationBackgroundColor}" + BindingContext="{Binding BindingContext, Source={RelativeSource TemplatedParent}}" + DateTime="{Binding DateTime, Source={RelativeSource TemplatedParent}}" + HeightRequest="{Binding NavigationHeightRequest}" LeftArrowCommand="{Binding LeftArrowCommand, Source={x:RelativeSource TemplatedParent}}" LeftArrowCommandParameter="{Binding LeftArrowCommandParameter, Source={RelativeSource TemplatedParent}}" - BindingContext="{Binding BindingContext, Source={RelativeSource TemplatedParent}}" RightArrowCommand="{Binding RightArrowCommand, Source={x:RelativeSource TemplatedParent}}" RightArrowCommandParameter="{Binding RightArrowCommandParameter, Source={RelativeSource TemplatedParent}}" - HeightRequest="{Binding NavigationHeightRequest}" Style="{StaticResource DefaultNavigationViewStyle}" - Text="{Binding Text, Source={RelativeSource TemplatedParent}}" TextColor="{Binding NavigationTextColor}"/>