diff --git a/maui/src/Accordion/AccordionItem.cs b/maui/src/Accordion/AccordionItem.cs
index 7aff5a63..e6eccbbd 100644
--- a/maui/src/Accordion/AccordionItem.cs
+++ b/maui/src/Accordion/AccordionItem.cs
@@ -317,14 +317,10 @@ public Color HeaderIconColor
///
internal int _itemIndex { get; set; }
- #endregion
-
- #region Private Properties
-
///
/// Gets or sets the instance of the accordion.
///
- SfAccordion? _accordion { get; set; }
+ internal SfAccordion? _accordion { get; set; }
#endregion
@@ -462,7 +458,7 @@ static void OnIsExpandedPropertyChanged(BindableObject bindable, object oldValue
// Content does not get collapsed when item is being collapsed in PCL view.
if (bindable is AccordionItem accordionItem)
{
- if (accordionItem._accordion != null && accordionItem._accordionItemView != null && accordionItem._accordionItemView.IsExpanded != accordionItem.IsExpanded)
+ if (accordionItem._accordion != null && accordionItem._accordion.IsViewLoaded && accordionItem._accordionItemView != null && accordionItem._accordionItemView.IsExpanded != accordionItem.IsExpanded)
{
accordionItem.OnIsExpandedChanging((bool)newValue);
}
@@ -479,7 +475,7 @@ static void OnIsExpandedPropertyChanged(BindableObject bindable, object oldValue
/// The new value of header property.
static void OnHeaderPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
- if (bindable is AccordionItem accordionItem && accordionItem._accordionItemView != null)
+ if (bindable is AccordionItem accordionItem && accordionItem._accordion != null && accordionItem._accordion.IsViewLoaded && accordionItem._accordionItemView != null)
{
accordionItem._accordionItemView.Header = (View)newValue;
}
@@ -494,18 +490,14 @@ static void OnHeaderPropertyChanged(BindableObject bindable, object oldValue, ob
static void OnContentPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
// When the Content is changed at runtime, need to update its visibility based on IsExpanded property.
- var content = newValue as View;
- if (bindable is AccordionItem accordionItem)
+ if (bindable is AccordionItem accordionItem && newValue is View content && accordionItem._accordion != null && accordionItem._accordion.IsViewLoaded)
{
- if (content != null)
- {
- content.IsVisible = accordionItem.IsExpanded;
- }
-
+ content.IsVisible = accordionItem.IsExpanded;
if (accordionItem._accordionItemView != null)
{
accordionItem._accordionItemView.Content = content;
}
+
}
}
@@ -517,7 +509,7 @@ static void OnContentPropertyChanged(BindableObject bindable, object oldValue, o
/// The new value of header background property.
static void OnHeaderBackgroundPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
- if (bindable is AccordionItem accordionItem && accordionItem._accordionItemView != null)
+ if (bindable is AccordionItem accordionItem && accordionItem._accordion != null && accordionItem._accordion.IsViewLoaded && accordionItem._accordionItemView != null)
{
accordionItem._accordionItemView.HeaderBackground = (Brush)newValue;
}
@@ -531,7 +523,7 @@ static void OnHeaderBackgroundPropertyChanged(BindableObject bindable, object ol
/// The new value of header icon color property.
static void OnHeaderIconColorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
- if (bindable is AccordionItem accordionItem && accordionItem._accordionItemView != null)
+ if (bindable is AccordionItem accordionItem && accordionItem._accordion != null && accordionItem._accordion.IsViewLoaded && accordionItem._accordionItemView != null)
{
accordionItem._accordionItemView.HeaderIconColor = (Color)newValue;
}
diff --git a/maui/src/Accordion/SfAccordion.cs b/maui/src/Accordion/SfAccordion.cs
index 766deb08..67062f0d 100644
--- a/maui/src/Accordion/SfAccordion.cs
+++ b/maui/src/Accordion/SfAccordion.cs
@@ -992,8 +992,8 @@ void OnAccordionLoaded(object? sender, System.EventArgs e)
{
if (!IsViewLoaded)
{
- AddAccordionItemsIntoView();
IsViewLoaded = true;
+ AddAccordionItemsIntoView();
}
}
diff --git a/maui/src/Expander/SfExpander.cs b/maui/src/Expander/SfExpander.cs
index ed0f18fb..d0edd261 100644
--- a/maui/src/Expander/SfExpander.cs
+++ b/maui/src/Expander/SfExpander.cs
@@ -1517,8 +1517,21 @@ protected override Size MeasureContent(double widthConstraint, double heightCons
}
}
+ double width = double.IsFinite(widthConstraint) ? widthConstraint : 0;
+ // To update width when loaded expander inside HorizontalStackLayout and AbsoluteLayout.
+ if (width == 0)
+ {
+#if !WINDOWS
+ var scaledScreenSize = new Size(DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density, DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density);
+#else
+ var scaledScreenSize = new Size(300, 300);
+#endif
+ double scaledWidth = Math.Min(scaledScreenSize.Width, scaledScreenSize.Height);
+ width = scaledWidth;
+ }
+
_expanderHeight = _headerMeasuredSize.Height + _contentMeasuredSize.Height + (_headerMeasuredSize.Height > 0 ? Padding.Bottom : 0);
- return new Size(widthConstraint, _expanderHeight);
+ return new Size(width, _expanderHeight);
}
@@ -1679,7 +1692,7 @@ static void OnHeaderPropertyChanged(BindableObject bindable, object oldValue, ob
var oldHeader = oldValue as View;
// When the Content is changed at runtime, need to update its visibility based on IsExpanded property.
- if (bindable is SfExpander expander)
+ if (bindable is SfExpander expander && expander.IsViewLoaded)
{
expander.OnHeaderChanged(newHeader, oldHeader);
}
@@ -1694,7 +1707,7 @@ static void OnHeaderPropertyChanged(BindableObject bindable, object oldValue, ob
static void OnHeaderIconPositionPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
// When the Content is changed at runtime, need to update its visibility based on IsExpanded property.
- if (bindable is SfExpander expander)
+ if (bindable is SfExpander expander && expander.IsViewLoaded)
{
expander.OnHeaderIconPositionChanged((ExpanderIconPosition)newValue, (ExpanderIconPosition)oldValue);
}
@@ -1749,7 +1762,7 @@ static void OnHeaderBackgroundPropertyChanged(BindableObject bindable, object ol
static void OnHeaderIconColorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
// When the Content is changed at runtime, need to update its visibility based on IsExpanded property.
- if (bindable is SfExpander expander)
+ if (bindable is SfExpander expander && expander.IsViewLoaded)
{
expander.OnIconColorChanged((Color)oldValue, (Color)newValue);
}
@@ -1764,15 +1777,17 @@ static void OnHeaderIconColorPropertyChanged(BindableObject bindable, object old
private static void OnAnimationDurationPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var expander = bindable as SfExpander;
- if (expander != null && (double)newValue == 0 && expander._expanderAnimation != null)
+ if (expander != null && (double)newValue == 0 && expander._expanderAnimation != null && expander.IsViewLoaded)
{
var animation = expander._expanderAnimation;
- if(animation.AnimationManager != null)
- // While setting Animation Duration as 0, the animation won't be stopped. So, removing it.
- // Since we are removing the animation, AnimationCompleted was not getting call. So, manually calling it.
- animation.AnimationManager.Remove(animation);
- expander.AnimationCompleted();
- expander.InvalidateForceLayout();
+ if (animation.AnimationManager != null)
+ {
+ // While setting Animation Duration as 0, the animation won't be stopped. So, removing it.
+ // Since we are removing the animation, AnimationCompleted was not getting call. So, manually calling it.
+ animation.AnimationManager.Remove(animation);
+ expander.AnimationCompleted();
+ expander.InvalidateForceLayout();
+ }
}
}
diff --git a/maui/src/PullToRefresh/SfPullToRefresh.cs b/maui/src/PullToRefresh/SfPullToRefresh.cs
index c765fc4f..e3cfe940 100644
--- a/maui/src/PullToRefresh/SfPullToRefresh.cs
+++ b/maui/src/PullToRefresh/SfPullToRefresh.cs
@@ -360,6 +360,13 @@ public SfPullToRefresh()
Children.Add(_progressCircleView);
ClipToBounds = true;
ThemeElement.InitializeThemeResources(this, "SfPullToRefreshTheme");
+
+ // Ensures the refreshing animation starts if IsRefreshing was set via global styles.
+ if (this.IsRefreshing && !this.ActualIsRefreshing)
+ {
+ this.StartRefreshing();
+ }
+
this.IsLayoutControl = true;
}
@@ -1869,8 +1876,27 @@ protected override Size MeasureContent(double widthConstraint, double heightCons
(PullableContent as IView).Measure(widthConstraint, heightConstraint);
}
- MeasureSfProgressCircleView(widthConstraint, heightConstraint);
- _previousMeasuredSize = new Size(widthConstraint, heightConstraint);
+ double width = double.IsFinite(widthConstraint) ? widthConstraint : 0;
+ double height = double.IsFinite(heightConstraint) ? heightConstraint : 0;
+ double screenWidth = 300;
+ double screenHeight = 300;
+#if !WINDOWS
+ screenWidth = DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density;
+ screenHeight = DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density;
+ width = screenWidth;
+ height = screenHeight;
+#else
+ if (width == 0)
+ {
+ width = screenWidth;
+ }
+ if (height == 0)
+ {
+ height = screenHeight;
+ }
+#endif
+ MeasureSfProgressCircleView(width, height);
+ _previousMeasuredSize = new Size(width, height);
}
return _previousMeasuredSize;
@@ -2057,7 +2083,7 @@ static void OnRefreshingViewTemplatePropertyChanged(BindableObject bindable, obj
static void OnRefreshViewHeightChanged(BindableObject bindable, object oldValue, object newValue)
{
SfPullToRefresh? pullToRefresh = bindable as SfPullToRefresh;
- if (pullToRefresh is not null)
+ if (pullToRefresh is not null && pullToRefresh.ProgressCircleView is not null)
{
pullToRefresh.ProgressCircleView.UpdateDrawProperties();
if ((pullToRefresh.IsPulling || pullToRefresh.ActualIsRefreshing) && pullToRefresh.ProgressCircleView.Content is null)
@@ -2078,7 +2104,7 @@ static void OnRefreshViewHeightChanged(BindableObject bindable, object oldValue,
static void OnRefreshViewWidthChanged(BindableObject bindable, object oldValue, object newValue)
{
SfPullToRefresh? pullToRefresh = bindable as SfPullToRefresh;
- if (pullToRefresh is not null)
+ if (pullToRefresh is not null && pullToRefresh.ProgressCircleView is not null)
{
pullToRefresh.ProgressCircleView.UpdateDrawProperties();
if ((pullToRefresh.IsPulling || pullToRefresh.ActualIsRefreshing) && pullToRefresh.ProgressCircleView.Content is null)
diff --git a/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfAccordionUnitTests.cs b/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfAccordionUnitTests.cs
index c703c71a..07c37744 100644
--- a/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfAccordionUnitTests.cs
+++ b/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfAccordionUnitTests.cs
@@ -585,6 +585,244 @@ public void AccordionStyle_WhenApplied_SetsCorrectProperties()
Assert.Equal(autoScrollPosition, accordion.AutoScrollPosition);
}
+ [Fact]
+ public void AnimationDuration_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var accordion = new SfAccordion { AnimationDuration = 200 };
+ Assert.Equal(200, accordion.AnimationDuration);
+ accordion.AnimationDuration = 500;
+ Assert.Equal(500, accordion.AnimationDuration);
+ }
+
+ [Fact]
+ public void AnimationEasing_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var accordion = new SfAccordion { AnimationEasing = ExpanderAnimationEasing.SinIn };
+ Assert.Equal(ExpanderAnimationEasing.SinIn, accordion.AnimationEasing);
+ accordion.AnimationEasing = ExpanderAnimationEasing.Linear;
+ Assert.Equal(ExpanderAnimationEasing.Linear, accordion.AnimationEasing);
+ }
+
+ [Fact]
+ public void AutoScrollPosition_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var accordion = new SfAccordion { AutoScrollPosition = AccordionAutoScrollPosition.Top };
+ Assert.Equal(AccordionAutoScrollPosition.Top, accordion.AutoScrollPosition);
+ accordion.AutoScrollPosition = AccordionAutoScrollPosition.None;
+ Assert.Equal(AccordionAutoScrollPosition.None, accordion.AutoScrollPosition);
+ }
+
+ [Fact]
+ public void HeaderIconPosition_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var accordion = new SfAccordion { HeaderIconPosition = ExpanderIconPosition.Start };
+ Assert.Equal(ExpanderIconPosition.Start, accordion.HeaderIconPosition);
+ accordion.HeaderIconPosition = ExpanderIconPosition.End;
+ Assert.Equal(ExpanderIconPosition.End, accordion.HeaderIconPosition);
+ }
+
+ [Fact]
+ public void ExpandMode_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var accordion = new SfAccordion { ExpandMode = AccordionExpandMode.Multiple };
+ Assert.Equal(AccordionExpandMode.Multiple, accordion.ExpandMode);
+ accordion.ExpandMode = AccordionExpandMode.SingleOrNone;
+ Assert.Equal(AccordionExpandMode.SingleOrNone, accordion.ExpandMode);
+ }
+
+ [Fact]
+ public void ItemSpacing_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var accordion = new SfAccordion { ItemSpacing = 100 };
+ Assert.Equal(100, accordion.ItemSpacing);
+ accordion.ItemSpacing = 200;
+ Assert.Equal(200, accordion.ItemSpacing);
+ }
+
+ [Fact]
+ public void HeaderBackground_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var accordion = new AccordionItem { HeaderBackground = Colors.Green };
+ Assert.Equal(Colors.Green, accordion.HeaderBackground);
+ accordion.HeaderBackground = Colors.Blue;
+ Assert.Equal(Colors.Blue, accordion.HeaderBackground);
+ }
+
+ [Fact]
+ public void HeaderIconColor_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var accordion = new AccordionItem { HeaderIconColor = Colors.Green };
+ Assert.Equal(Colors.Green, accordion.HeaderIconColor);
+ accordion.HeaderIconColor = Colors.Blue;
+ Assert.Equal(Colors.Blue, accordion.HeaderIconColor);
+ }
+
+ [Fact]
+ public void IsExpanded_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var accordion = new AccordionItem { IsExpanded = true };
+ Assert.True(accordion.IsExpanded);
+ accordion.IsExpanded = false;
+ Assert.False(accordion.IsExpanded);
+ }
+
+ [Fact]
+ public void AccordionItemStyle_WhenApplied_SetsCorrectProperties()
+ {
+ Color color = new Color();
+ color = Color.FromRgba("#233434");
+ Color color2 = new Color();
+ color2 = Color.FromRgba("#FF0000");
+ var style = new Style(typeof(Syncfusion.Maui.Toolkit.Accordion.AccordionItem));
+ style.Setters.Add(new Setter
+ {
+ Property = Syncfusion.Maui.Toolkit.Accordion.AccordionItem.HeaderBackgroundProperty,
+ Value = color
+ });
+ style.Setters.Add(new Setter
+ {
+ Property = Syncfusion.Maui.Toolkit.Accordion.AccordionItem.HeaderIconColorProperty,
+ Value = color2
+ });
+ style.Setters.Add(new Setter
+ {
+ Property = Syncfusion.Maui.Toolkit.Accordion.AccordionItem.IsExpandedProperty,
+ Value = true
+ });
+ var resources = new ResourceDictionary();
+ resources.Add("AccordionStyle", style);
+ Application.Current = new Application();
+ Application.Current.Resources = resources;
+ var accordion = new Syncfusion.Maui.Toolkit.Accordion.AccordionItem();
+ // Act
+ accordion.Style = (Style)Application.Current.Resources["AccordionStyle"];
+ Assert.Equal(color, accordion.HeaderBackground);
+ Assert.Equal(color2, accordion.HeaderIconColor);
+ Assert.True(accordion.IsExpanded);
+ }
+
+ [Fact]
+ public void SfAccordion_ShouldBeAddedToStackLayout()
+ {
+ // Arrange
+ var stackLayout = new StackLayout();
+ var accordion = new SfAccordion
+ {
+ ExpandMode = AccordionExpandMode.Single
+ };
+ var label = new Label
+ {
+ Text = "Accordion Content",
+ };
+ var accordionItem = new AccordionItem
+ {
+ Header = new Label { Text = "Accordion Header", AutomationId = "accordionHeader" },
+ Content = label
+ };
+ // Act
+ accordion.Items.Add(accordionItem);
+ stackLayout.Children.Add(accordion);
+ // Assert
+ Assert.Contains(accordion, stackLayout.Children);
+ }
+
+ [Fact]
+ public void SfAccordion_ShouldBeAddedToAbsoluteLayout()
+ {
+ // Arrange
+ var absoluteLayout = new StackLayout();
+ var accordion = new SfAccordion
+ {
+ ExpandMode = AccordionExpandMode.Single
+ };
+ var label = new Label
+ {
+ Text = "Accordion Content",
+ };
+ var accordionItem = new AccordionItem
+ {
+ Header = new Label { Text = "Accordion Header", AutomationId = "accordionHeader" },
+ Content = label
+ };
+ // Act
+ accordion.Items.Add(accordionItem);
+ absoluteLayout.Children.Add(accordion);
+ // Assert
+ Assert.Contains(accordion, absoluteLayout.Children);
+ }
+ [Fact]
+ public void SfAccordion_ShouldBeAddedToHorizontalStackLayout()
+ {
+ // Arrange
+ var stackLayout = new HorizontalStackLayout();
+ var accordion = new SfAccordion
+ {
+ ExpandMode = AccordionExpandMode.Single
+ };
+ var label = new Label
+ {
+ Text = "Accordion Content",
+ };
+ var accordionItem = new AccordionItem
+ {
+ Header = new Label { Text = "Accordion Header", AutomationId = "accordionHeader" },
+ Content = label
+ };
+ // Act
+ accordion.Items.Add(accordionItem);
+ stackLayout.Children.Add(accordion);
+ // Assert
+ Assert.Contains(accordion, stackLayout.Children);
+ }
+ [Fact]
+ public void SfAccordion_ShouldBeAddedToFlexLayout()
+ {
+ // Arrange
+ var flexLayout = new FlexLayout();
+ var accordion = new SfAccordion
+ {
+ ExpandMode = AccordionExpandMode.Single
+ };
+ var label = new Label
+ {
+ Text = "Accordion Content",
+ };
+ var accordionItem = new AccordionItem
+ {
+ Header = new Label { Text = "Accordion Header", AutomationId = "accordionHeader" },
+ Content = label
+ };
+ // Act
+ accordion.Items.Add(accordionItem);
+ flexLayout.Children.Add(accordion);
+ // Assert
+ Assert.Contains(accordion, flexLayout.Children);
+ }
+ [Fact]
+ public void SfAccordion_ShouldBeAddedToGrid()
+ {
+ // Arrange
+ var grid = new Grid();
+ var accordion = new SfAccordion
+ {
+ ExpandMode = AccordionExpandMode.Single
+ };
+ var label = new Label
+ {
+ Text = "Accordion Content",
+ };
+ var accordionItem = new AccordionItem
+ {
+ Header = new Label { Text = "Accordion Header", AutomationId = "accordionHeader" },
+ Content = label
+ };
+ // Act
+ accordion.Items.Add(accordionItem);
+ grid.Children.Add(accordion);
+ // Assert
+ Assert.Contains(accordion, grid.Children);
+ }
+
#endregion
#region Methods
@@ -605,6 +843,7 @@ public void UpdateAccordionItems_SingleExpandMode_ExpandsFirstItem(bool initialS
ExpandMode = AccordionExpandMode.Single
};
+ accordion.IsViewLoaded = true;
accordion.UpdateAccordionItemsBasedOnExpandModes(false);
Assert.Equal(expectedState, accordion.Items[0]._accordionItemView?.IsExpanded);
}
@@ -631,6 +870,8 @@ public void UpdateAccordionItemsBasedOnExpandModes_MultipleItemsExpanded(
ExpandMode = AccordionExpandMode.Single
};
+ var accordionItem = new AccordionItem();
+ accordion.IsViewLoaded = true;
accordion.UpdateAccordionItemsBasedOnExpandModes(false);
Assert.Equal(firstItemExpectedState, accordion.Items[0]._accordionItemView?.IsExpanded);
Assert.Equal(secondItemExpectedState, accordion.Items[1]._accordionItemView?.IsExpanded);
@@ -945,6 +1186,9 @@ public void OnBindingContextChanged_SetsContentBindingContext_WhenHeaderIsNotNul
public void OnHeaderPropertyChanged_SetsAccordionItemViewHeader_WhenHeaderIsNotNull()
{
var accordionItem = new AccordionItem();
+ var accordion = new SfAccordion();
+ accordionItem._accordion = accordion;
+ accordionItem._accordion.IsViewLoaded = true;
var contentView = new ContentView();
var accordionItemView = new AccordionItemView();
accordionItem._accordionItemView = accordionItemView;
@@ -969,7 +1213,9 @@ public void OnContentPropertyChanged_SetsContentVisibilityAndViewContent_WhenCon
{
IsExpanded = true
};
-
+ var accordion = new SfAccordion();
+ accordionItem._accordion = accordion;
+ accordionItem._accordion.IsViewLoaded = true;
var contentView = new ContentView();
var accordionItemView = new AccordionItemView();
accordionItem._accordionItemView = accordionItemView;
@@ -987,6 +1233,9 @@ public void OnContentPropertyChanged_SetsContentVisibilityAndViewContent_WhenCon
IsExpanded = true
};
+ var accordion = new SfAccordion();
+ accordionItem._accordion = accordion;
+ accordionItem._accordion.IsViewLoaded = true;
// Create a new AccordionItemView and set it to _accordionItemView
var accordionItemView = new AccordionItemView();
accordionItem._accordionItemView = accordionItemView;
@@ -1016,6 +1265,9 @@ public void OnContentPropertyChanged_SetsContentVisibilityAndViewContent_WhenCon
public void OnHeaderBackgroundPropertyChanged_UpdatesHeaderBackground(string brushColor)
{
var accordionItem = new AccordionItem();
+ var accordion = new SfAccordion();
+ accordionItem._accordion = accordion;
+ accordionItem._accordion.IsViewLoaded = true;
var accordionItemView = new AccordionItemView();
accordionItem._accordionItemView = accordionItemView;
var newBrush = new SolidColorBrush(Color.FromArgb(brushColor));
@@ -1030,6 +1282,9 @@ public void OnHeaderBackgroundPropertyChanged_UpdatesHeaderBackground(string bru
public void OnHeaderIconColorPropertyChanged_UpdatesHeaderIconColor(string colorHex)
{
var accordionItem = new AccordionItem();
+ var accordion = new SfAccordion();
+ accordionItem._accordion = accordion;
+ accordionItem._accordion.IsViewLoaded = true;
var accordionItemView = new AccordionItemView();
accordionItem._accordionItemView = accordionItemView;
var newColor = Color.FromArgb(colorHex);
diff --git a/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs b/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs
index f6bf0ad3..fc836d56 100644
--- a/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs
+++ b/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs
@@ -825,6 +825,212 @@ public void IsMouseHover_SetValue_ReturnsExpected(bool expectedValue)
}
}
+ [Fact]
+ public void AnimationDuration_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var expander = new SfExpander { AnimationDuration = 200 };
+ Assert.Equal(200, expander.AnimationDuration);
+ expander.AnimationDuration = 500;
+ Assert.Equal(500, expander.AnimationDuration);
+ }
+
+ [Fact]
+ public void AnimationEasing_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var expander = new SfExpander { AnimationEasing = ExpanderAnimationEasing.SinIn };
+ Assert.Equal(ExpanderAnimationEasing.SinIn, expander.AnimationEasing);
+ expander.AnimationEasing = ExpanderAnimationEasing.Linear;
+ Assert.Equal(ExpanderAnimationEasing.Linear, expander.AnimationEasing);
+ }
+
+ [Fact]
+ public void HeaderIconPosition_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var expander = new SfExpander { HeaderIconPosition = ExpanderIconPosition.Start };
+ Assert.Equal(ExpanderIconPosition.Start, expander.HeaderIconPosition);
+ expander.HeaderIconPosition = ExpanderIconPosition.End;
+ Assert.Equal(ExpanderIconPosition.End, expander.HeaderIconPosition);
+ }
+
+ [Fact]
+ public void HeaderBackground_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var expander = new SfExpander { HeaderBackground = Colors.Green };
+ Assert.Equal(Colors.Green, expander.HeaderBackground);
+ expander.HeaderBackground = Colors.Blue;
+ Assert.Equal(Colors.Blue, expander.HeaderBackground);
+ }
+
+ [Fact]
+ public void HeaderIconColor_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var expander = new SfExpander { HeaderIconColor = Colors.Green };
+ Assert.Equal(Colors.Green, expander.HeaderIconColor);
+ expander.HeaderIconColor = Colors.Blue;
+ Assert.Equal(Colors.Blue, expander.HeaderIconColor);
+ }
+
+ [Fact]
+ public void IsExpanded_SetValue_Runtime_ShouldUpdateProperty()
+ {
+ var expander = new SfExpander { IsExpanded = true };
+ Assert.True(expander.IsExpanded);
+ expander.IsExpanded = false;
+ Assert.False(expander.IsExpanded);
+ }
+
+ [Fact]
+ public void ExpanderStyle_WhenApplied_SetsCorrectProperties()
+ {
+ // Arrange
+ var animationDuration = 100;
+ ExpanderAnimationEasing easing = new ExpanderAnimationEasing();
+ easing = ExpanderAnimationEasing.SinInOut;
+ ExpanderIconPosition expanderIconPosition = new ExpanderIconPosition();
+ expanderIconPosition = ExpanderIconPosition.Start;
+ Color color = new Color();
+ color = Colors.Aquamarine;
+ Color color2 = new Color();
+ color2 = Colors.GreenYellow;
+ var style = new Style(typeof(Syncfusion.Maui.Toolkit.Expander.SfExpander));
+ style.Setters.Add(new Setter
+ {
+ Property = Syncfusion.Maui.Toolkit.Expander.SfExpander.AnimationDurationProperty,
+ Value = animationDuration
+ });
+ style.Setters.Add(new Setter
+ {
+ Property = Syncfusion.Maui.Toolkit.Expander.SfExpander.HeaderIconPositionProperty,
+ Value = expanderIconPosition
+ });
+ style.Setters.Add(new Setter
+ {
+ Property = Syncfusion.Maui.Toolkit.Expander.SfExpander.AnimationEasingProperty,
+ Value = easing
+ });
+ style.Setters.Add(new Setter
+ {
+ Property = Syncfusion.Maui.Toolkit.Expander.SfExpander.HeaderBackgroundProperty,
+ Value = color
+ });
+ style.Setters.Add(new Setter
+ {
+ Property = Syncfusion.Maui.Toolkit.Expander.SfExpander.IsExpandedProperty,
+ Value = true
+ });
+ style.Setters.Add(new Setter
+ {
+ Property = Syncfusion.Maui.Toolkit.Expander.SfExpander.HeaderIconColorProperty,
+ Value = color2
+ });
+ var resources = new ResourceDictionary();
+ resources.Add("ExpanderStyle", style);
+ Application.Current = new Application();
+ Application.Current.Resources = resources;
+ var expander = new Syncfusion.Maui.Toolkit.Expander.SfExpander();
+ // Act
+ expander.Style = (Style)Application.Current.Resources["ExpanderStyle"];
+ // Assert
+ Assert.Equal(animationDuration, expander.AnimationDuration);
+ Assert.Equal(expanderIconPosition, expander.HeaderIconPosition);
+ Assert.Equal(easing, expander.AnimationEasing);
+ Assert.Equal(color, expander.HeaderBackground);
+ Assert.Equal(color2, expander.HeaderIconColor);
+ Assert.True(expander.IsExpanded);
+ }
+
+ [Fact]
+ public void SfExpander_ShouldBeAddedToStackLayout()
+ {
+ // Arrange
+ var stackLayout = new StackLayout();
+ var label = new Label { Text = "Expander Content", };
+ var expander = new SfExpander
+ {
+ Header = new Label { Text = "Tap to Expand" },
+ Content = label,
+ AutomationId = "myExpander"
+ };
+
+ // Act
+ stackLayout.Children.Add(expander);
+
+ // Assert
+ Assert.Contains(expander, stackLayout.Children);
+ }
+
+ [Fact]
+ public void SfExpander_ShouldBeAddedToAbsoluteLayout()
+ {
+ // Arrange
+ var absoluteLayout = new AbsoluteLayout();
+ var label = new Label { Text = "Expander Content", };
+ var expander = new SfExpander
+ {
+ Header = new Label { Text = "Tap to Expand" },
+ Content = label,
+ AutomationId = "myExpander"
+ };
+ // Act
+ absoluteLayout.Children.Add(expander);
+ // Assert
+ Assert.Contains(expander, absoluteLayout.Children);
+ }
+
+ [Fact]
+ public void SfExpander_ShouldBeAddedToHorizontalStackLayout()
+ {
+ // Arrange
+ var stackLayout = new HorizontalStackLayout();
+ var label = new Label { Text = "Expander Content", };
+ var expander = new SfExpander
+ {
+ Header = new Label { Text = "Tap to Expand" },
+ Content = label,
+ AutomationId = "myExpander"
+ };
+ // Act
+ stackLayout.Children.Add(expander);
+ // Assert
+ Assert.Contains(expander, stackLayout.Children);
+ }
+
+ [Fact]
+ public void SfExpander_ShouldBeAddedToFlexLayout()
+ {
+ // Arrange
+ var flexLayout = new FlexLayout();
+ var label = new Label { Text = "Expander Content", };
+ var expander = new SfExpander
+ {
+ Header = new Label { Text = "Tap to Expand" },
+ Content = label,
+ AutomationId = "myExpander"
+ };
+ // Act
+ flexLayout.Children.Add(expander);
+ // Assert
+ Assert.Contains(expander, flexLayout.Children);
+ }
+
+ [Fact]
+ public void SfExpander_ShouldBeAddedToGrid()
+ {
+ // Arrange
+ var grid = new Grid();
+ var label = new Label { Text = "Expander Content", };
+ var expander = new SfExpander
+ {
+ Header = new Label { Text = "Tap to Expand" },
+ Content = label,
+ AutomationId = "myExpander"
+ };
+ // Act
+ grid.Children.Add(expander);
+ // Assert
+ Assert.Contains(expander, grid.Children);
+ }
+
#endregion
#region Methods
diff --git a/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Notification/SfPullToRefreshUnitTests.cs b/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Notification/SfPullToRefreshUnitTests.cs
index 04448ea1..1fdacb63 100644
--- a/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Notification/SfPullToRefreshUnitTests.cs
+++ b/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Notification/SfPullToRefreshUnitTests.cs
@@ -497,7 +497,7 @@ public void MeasureContent_ShouldMeasurePullableContent_WhenNotPullingAndNotRefr
var result = InvokePrivateMethod(pullToRefresh, "MeasureContent", widthConstraint, heightConstraint);
- Assert.Equal(new Size(widthConstraint, heightConstraint), result);
+ Assert.Equal(new Size(double.NaN,double.NaN), result);
}
[Fact]
@@ -586,7 +586,7 @@ public void MeasureContent_ShouldMeasurePullableContent_WhenNotPulling()
InvokePrivateMethod(pullToRefresh, "MeasureContent", widthConstraint, heightConstraint);
Assert.False(pullableContent.IsPulling);
var previousMeasuredSize = (Size?)typeof(SfPullToRefresh).GetField("_previousMeasuredSize", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(pullToRefresh);
- Assert.Equal(new Size(widthConstraint, heightConstraint), previousMeasuredSize);
+ Assert.Equal(new Size(double.NaN,double.NaN), previousMeasuredSize);
}
[Fact]