зеркало из https://github.com/DeGsoft/maui-linux.git
[C] Cascade StyleSheets defined at Application level (#1590)
fixes #1553
This commit is contained in:
Родитель
d46d6fb403
Коммит
5a7cdb081e
|
@ -17,6 +17,13 @@ namespace Xamarin.Forms.StyleSheets.UnitTests
|
||||||
Internals.Registrar.RegisterAll(new Type[0]);
|
Internals.Registrar.RegisterAll(new Type[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TearDown]
|
||||||
|
public void TearDown()
|
||||||
|
{
|
||||||
|
Device.PlatformServices = null;
|
||||||
|
Application.ClearCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PropertiesAreApplied()
|
public void PropertiesAreApplied()
|
||||||
{
|
{
|
||||||
|
@ -78,5 +85,17 @@ namespace Xamarin.Forms.StyleSheets.UnitTests
|
||||||
var layout = new StackLayout();
|
var layout = new StackLayout();
|
||||||
Assert.That(layout.GetValue(TextElement.TextColorProperty), Is.EqualTo(Color.Default));
|
Assert.That(layout.GetValue(TextElement.TextColorProperty), Is.EqualTo(Color.Default));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StyleSheetsOnAppAreApplied()
|
||||||
|
{
|
||||||
|
var app = new MockApplication();
|
||||||
|
app.Resources.Add(StyleSheet.FromString("label{ color: red;}"));
|
||||||
|
var page = new ContentPage {
|
||||||
|
Content = new Label()
|
||||||
|
};
|
||||||
|
app.MainPage = page;
|
||||||
|
Assert.That((page.Content as Label).TextColor, Is.EqualTo(Color.Red));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -41,8 +41,8 @@ namespace Xamarin.Forms
|
||||||
return;
|
return;
|
||||||
var sheets = new List<StyleSheet>();
|
var sheets = new List<StyleSheet>();
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
var visualParent = parent as VisualElement;
|
var resourceProvider = parent as IResourcesProvider;
|
||||||
var vpSheets = visualParent?.GetStyleSheets();
|
var vpSheets = resourceProvider?.GetStyleSheets();
|
||||||
if (vpSheets != null)
|
if (vpSheets != null)
|
||||||
sheets.AddRange(vpSheets);
|
sheets.AddRange(vpSheets);
|
||||||
parent = parent.Parent;
|
parent = parent.Parent;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче