Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ protected virtual void UpdateEmptyView()
break;
}

if (_formsEmptyView is not null && _emptyView is not null)
{
var margin = _formsEmptyView.Margin;
_emptyView.Margin = WinUIHelpers.CreateThickness(margin.Left, margin.Top, margin.Right, margin.Bottom);
}

(ListViewBase as IEmptyView)?.SetEmptyView(_emptyView, _formsEmptyView);

UpdateEmptyViewVisibility();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue8494.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 8494, "Margin doesn't work inside CollectionView EmptyView", PlatformAffected.UWP)]

public class Issue8494 : ContentPage
{
Issue8494EmptyViewModel ViewModel;

public Issue8494()
{
ViewModel = new Issue8494EmptyViewModel();
BindingContext = ViewModel;
var label = new Label
{
Text = "EmptyView should be laid out with respect to the Specified margin",
AutomationId = "EmptyViewDescriptionLabel",
};

var emptyViewLayout = new StackLayout
Comment thread
Dhivya-SF4094 marked this conversation as resolved.
{
Margin = new Thickness(40),
Background = Colors.Yellow,
Children =
{
new Label
{
Text = "EmptyView with Margin.",
BackgroundColor = Colors.Blue,
HorizontalTextAlignment = TextAlignment.Center,
},
}
};

var collectionView = new CollectionView
{
ItemsSource = ViewModel.ItemList,
BackgroundColor = Colors.Green,
EmptyView = emptyViewLayout,
};

var grid = new Grid
{
RowDefinitions =
{
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Star },
}
};

grid.Add(label, 0, 0);
grid.Add(collectionView, 0, 1);
Content = grid;
}
}

public class Issue8494EmptyViewModel
{
public ObservableCollection<string> ItemList { get; set; }

public Issue8494EmptyViewModel()
{
ItemList = new ObservableCollection<string>();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue8494 : _IssuesUITest
{
public Issue8494(TestDevice testDevice) : base(testDevice)
{
}
public override string Issue => "Margin doesn't work inside CollectionView EmptyView";

[Test]
[Category(UITestCategories.CollectionView)]
public void CheckEmptyViewMargin()
{
App.WaitForElement("EmptyViewDescriptionLabel");
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading