}
+ [Test]
+ public async Task TitleViewLogicalChild()
+ {
+ Shell shell = new Shell();
+ ContentPage page = new ContentPage();
+ shell.Items.Add(CreateShellItem(page));
+ page.BindingContext = new { Text = "Binding" };
+
+ // setup title view
+ StackLayout layout = new StackLayout() { BackgroundColor = Color.White };
+ Label label = new Label();
+ label.SetBinding(Label.TextProperty, "Text");
+ layout.Children.Add(label);
+ Shell.SetTitleView(page, layout);
+
+
+ Assert.True(page.ChildrenNotDrawnByThisElement.Contains(layout));
+ }
+
+
+ [Test]
+ public async Task FlyoutHeaderLogicalChild()
+ {
+ Shell shell = new Shell();
+ ContentPage page = new ContentPage();
+ shell.Items.Add(CreateShellItem(page));
+
+ // setup title view
+ StackLayout layout = new StackLayout() { BackgroundColor = Color.White };
+ Label label = new Label();
+ label.SetBinding(Label.TextProperty, "Text");
+ layout.Children.Add(label);
+
+
+ shell.FlyoutHeader = null;
+ shell.FlyoutHeader = layout;
+
+ Assert.True(shell.ChildrenNotDrawnByThisElement.Contains(layout));
+ shell.FlyoutHeader = null;
+
+ Assert.False(shell.ChildrenNotDrawnByThisElement.Contains(layout));
+ }
+
+
[Test]
public async Task TabBarAutoCreation()
{
}
internal virtual ReadOnlyCollection<Element> LogicalChildrenInternal => EmptyChildren;
+ internal IEnumerable<Element> AllChildren
+ {
+ get
+ {
+ foreach (var child in LogicalChildrenInternal)
+ yield return child;
+
+ foreach (var child in ChildrenNotDrawnByThisElement)
+ yield return child;
+ }
+ }
+
+ internal virtual IEnumerable<Element> ChildrenNotDrawnByThisElement => EmptyChildren;
+
[EditorBrowsable(EditorBrowsableState.Never)]
public ReadOnlyCollection<Element> LogicalChildren => LogicalChildrenInternal;
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
base.OnPropertyChanged(propertyName);
-
- IPropertyPropagationController titleView = Shell.GetTitleView(this) ?? NavigationPage.GetTitleView(this);
- if(titleView != null)
- PropertyPropagationExtensions.PropagatePropertyChanged(propertyName, this, new[] { titleView });
+ foreach(var logicalChildren in ChildrenNotDrawnByThisElement)
+ {
+ if(logicalChildren is IPropertyPropagationController controller)
+ PropertyPropagationExtensions.PropagatePropertyChanged(propertyName, this, new[] { logicalChildren });
+ }
if (_effects == null || _effects.Count == 0)
return;
[EditorBrowsable(EditorBrowsableState.Never)]
public ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
+ internal override IEnumerable<Element> ChildrenNotDrawnByThisElement
+ {
+ get
+ {
+ var titleviewPart1TheShell = Shell.GetTitleView(this);
+ var titleViewPart2TheNavBar = NavigationPage.GetTitleView(this);
+
+ if (titleviewPart1TheShell != null)
+ yield return titleviewPart1TheShell;
+
+ if (titleViewPart2TheNavBar != null)
+ yield return titleViewPart2TheNavBar;
+
+ }
+ }
+
internal override ReadOnlyCollection<Element> LogicalChildrenInternal =>
_logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren));
{
await CurrentItem.CurrentItem.GoToAsync(navigationRequest, queryData, animate);
}
-
+
//if (Routing.CompareWithRegisteredRoutes(shellItemRoute))
//{
// var shellItem = ShellItem.GetShellItemFromRouteName(shellItemRoute);
}
}
+ internal override IEnumerable<Element> ChildrenNotDrawnByThisElement
+ {
+ get
+ {
+ if (FlyoutHeaderView != null)
+ yield return FlyoutHeaderView;
+ }
+ }
+
+
protected virtual void OnNavigated(ShellNavigatedEventArgs args)
{
if (_accumulateNavigatedEvents)
{
readonly Shell _shell;
- NavigationProxy SectionProxy => _shell.CurrentItem.CurrentItem.NavigationProxy;
+ NavigationProxy SectionProxy => _shell.CurrentItem.CurrentItem.NavigationProxy;
public NavigationImpl(Shell shell) => _shell = shell;
UpdateDisplayedPage();
}
+ internal override IEnumerable<Element> ChildrenNotDrawnByThisElement => Items;
+
protected virtual void OnInsertPageBefore(Page page, Page before)
{
var index = _navStack.IndexOf(before);
void Apply(Element styleable)
{
ApplyCore(styleable);
- foreach (var child in styleable.LogicalChildrenInternal)
+ foreach (var child in styleable.AllChildren)
((IStyle)this).Apply(child);
}
using System;
using System.Collections.Generic;
+using System.Reflection;
using System.Text;
+using Xamarin.Forms.StyleSheets;
namespace Xamarin.Forms.Sandbox
{
// This code is called from the App Constructor so just initialize the main page of the application here
void InitializeMainPage()
{
- //MainPage = CreateStackLayoutPage(new[] { new Button() { Text = "text" } });
+
+
+ this.Resources.Add(StyleSheet.FromAssemblyResource(
+ IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly,
+ "Xamarin.Forms.Sandbox.Styles.css"));
+
+ //MainPage = CreateStackLayoutPage(new[] { new Button() { Text = "text" } });
//MainPage.Visual = VisualMarker.Material;
- MainPage = new MainPage();
+ MainPage = new ShellPage();
+
+ // MainPage = new NavigationPage(new MainPage());
}
}
}
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Xamarin.Forms.Sandbox.MainPage"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="true">
- <ContentPage.Content>
- <StackLayout>
+
+ <NavigationPage.TitleView>
+ <Grid>
<Button Text="I am a Button" />
- </StackLayout>
- </ContentPage.Content>
+ </Grid>
+ </NavigationPage.TitleView>
+ <StackLayout>
+ <Button Text="I am a Button" />
+ </StackLayout>
</ContentPage>
\ No newline at end of file
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage : ContentPage
- {
+ {
public MainPage()
{
InitializeComponent();
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- x:Class="Xamarin.Forms.Sandbox.ShellPage">
+ x:Class="Xamarin.Forms.Sandbox.ShellPage"
+ xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
+ ios:Page.UseSafeArea="true">
- <ShellContent Title="test">
- <ContentPage></ContentPage>
+ <Shell.FlyoutHeader>
+ <StackLayout>
+ <Button Text="I am a Button" />
+ </StackLayout>
+ </Shell.FlyoutHeader>
+ <ShellContent>
+ <ContentPage>
+ <Shell.TitleView>
+ <StackLayout>
+ <Button Text="I am a Button" />
+ </StackLayout>
+ </Shell.TitleView>
+ <StackLayout>
+ <Button Text="I am a Button" />
+ </StackLayout>
+ </ContentPage>
</ShellContent>
</Shell>
\ No newline at end of file
--- /dev/null
+button {
+ background-color:green;
+ color:#FFFFFF
+}