@@ -605,6 +605,20 @@ public partial class SfCalendar
605
605
CalendarRelativePosition . AlignTop ,
606
606
propertyChanged : OnRelativePositionChanged ) ;
607
607
608
+ /// <summary>
609
+ /// Identifies the <see cref="RelativeView"/> dependency property.
610
+ /// </summary>
611
+ /// <value>
612
+ /// The identifier for <see cref="RelativeView"/> dependency property.
613
+ /// </value>
614
+ public static readonly BindableProperty RelativeViewProperty =
615
+ BindableProperty . Create (
616
+ nameof ( RelativeView ) ,
617
+ typeof ( View ) ,
618
+ typeof ( SfCalendar ) ,
619
+ null ,
620
+ propertyChanged : OnRelativeViewChanged ) ;
621
+
608
622
#if WINDOWS
609
623
/// <summary>
610
624
/// Identifies the <see cref="FlowDirectionProperty"/> dependency property.
@@ -2265,6 +2279,47 @@ public CalendarRelativePosition RelativePosition
2265
2279
set { SetValue ( RelativePositionProperty , value ) ; }
2266
2280
}
2267
2281
2282
+ /// <summary>
2283
+ /// Gets or sets the view relative to which the calendar dialog should be displayed based on the RelativePosition.
2284
+ /// <seealso cref="SfCalendar.RelativePosition"/>
2285
+ /// </summary>
2286
+ /// <remarks>
2287
+ /// It is only applicable for RelativeDialog mode. If no relative view is given, the calendar will be set as the relative view.
2288
+ /// </remarks>
2289
+ /// <example>
2290
+ /// The following code demonstrates, how to use the RelativeView property in the calendar
2291
+ /// #[XAML](#tab/tabid-1)
2292
+ /// <code Lang="XAML"><![CDATA[
2293
+ /// <Grid WidthRequest="500">
2294
+ /// <calendar:SfCalendar x:Name="calendar"
2295
+ /// Mode="RelativeDialog"
2296
+ /// RelativePosition="AlignToRightOf"
2297
+ /// RelativeView="{x:Reference calendarButton}">
2298
+ /// </calendar:SfCalendar>
2299
+ /// <Button Text="Open calendar"
2300
+ /// x:Name="calendarButton"
2301
+ /// Clicked="Button_Clicked"
2302
+ /// HorizontalOptions="Center"
2303
+ /// VerticalOptions="Center"
2304
+ /// HeightRequest="50"
2305
+ /// WidthRequest="150">
2306
+ /// </Button>
2307
+ /// </Grid>
2308
+ /// ]]></code>
2309
+ /// # [C#](#tab/tabid-2)
2310
+ /// <code Lang="C#"><![CDATA[
2311
+ /// private void Button_Clicked(object sender, System.EventArgs e)
2312
+ /// {
2313
+ /// this.calendar.IsOpen = true;
2314
+ /// }
2315
+ /// ]]></code>
2316
+ /// </example>
2317
+ public View RelativeView
2318
+ {
2319
+ get { return ( View ) GetValue ( RelativeViewProperty ) ; }
2320
+ set { SetValue ( RelativeViewProperty , value ) ; }
2321
+ }
2322
+
2268
2323
//// TODO: Workaround for RTL (Right-to-Left) layout issue - The coordinate points are not calculated correctly in RTL layouts,
2269
2324
//// causing incorrect positioning. This flag helps to apply RTL-specific adjustments.
2270
2325
#if WINDOWS
@@ -2497,7 +2552,7 @@ protected override void OnPropertyChanged(string? propertyName = null)
2497
2552
CloseCalendarPopup ( ) ;
2498
2553
}
2499
2554
}
2500
- else if ( propertyName == "FlowDirection" )
2555
+ else if ( propertyName == "FlowDirection" )
2501
2556
{
2502
2557
if ( FlowDirection == FlowDirection . RightToLeft )
2503
2558
{
@@ -3519,6 +3574,26 @@ static void OnRelativePositionChanged(BindableObject bindable, object oldValue,
3519
3574
}
3520
3575
}
3521
3576
3577
+ /// <summary>
3578
+ /// Called when <see cref="RelativeView"/> property changed.
3579
+ /// </summary>
3580
+ /// <param name="bindable">The bindable.</param>
3581
+ /// <param name="oldValue">The old value.</param>
3582
+ /// <param name="newValue">The new value.</param>
3583
+ static void OnRelativeViewChanged ( BindableObject bindable , object oldValue , object newValue )
3584
+ {
3585
+ SfCalendar ? calendar = bindable as SfCalendar ;
3586
+ if ( calendar == null )
3587
+ {
3588
+ return ;
3589
+ }
3590
+
3591
+ if ( calendar . IsOpen && calendar . Mode == CalendarMode . RelativeDialog && calendar . RelativeView != null )
3592
+ {
3593
+ calendar . ShowPopup ( ) ;
3594
+ }
3595
+ }
3596
+
3522
3597
#if WINDOWS
3523
3598
/// <summary>
3524
3599
/// Method invoke when flow direction property changed.
0 commit comments