public static void SetToolbarPlacement(BindableObject element, ToolbarPlacement value) { if (element.IsSet(ToolbarPlacementProperty) && GetToolbarPlacement(element) != value) { throw new InvalidOperationException("Changing the tabs placement after it's been set is not supported."); } element.SetValue(ToolbarPlacementProperty, value); }
static void UpdateToolbarPlacement(CommandBar toolbar, ToolbarPlacement toolbarPlacement, WBorder bottomCommandBarArea, WBorder topCommandBarArea, WBorder titleArea) { // Figure out what's hosting the command bar right now var current = toolbar.Parent as WBorder; // And figure out where it should be WBorder target; switch (toolbarPlacement) { case ToolbarPlacement.Top: target = topCommandBarArea; break; case ToolbarPlacement.Bottom: target = bottomCommandBarArea; break; case ToolbarPlacement.Default: default: target = Device.Idiom == TargetIdiom.Phone ? bottomCommandBarArea : topCommandBarArea; break; } if (current == null || target == null || current == target) { return; } // Remove the command bar from its current host and add it to the new one current.Child = null; target.Child = toolbar; if (titleArea != null) { if (target == bottomCommandBarArea) { // If the title is hosted in the command bar and we're moving the command bar to the bottom, // put the title into the topCommandBarArea toolbar.Content = null; topCommandBarArea.Child = titleArea; } else { // Put the title back into the command bar toolbar.Content = titleArea; } } }
public static void UpdateToolbarPlacement(CommandBar toolbar, ToolbarPlacement toolbarPlacement, Border bottomCommandBarArea, Border topCommandBarArea) { if (toolbar == null || bottomCommandBarArea == null || topCommandBarArea == null) { // Haven't applied the template yet, so we're not ready to do this return; } // Figure out what's hosting the command bar right now var current = toolbar.Parent as Border; // And figure out where it should be Border target; switch (toolbarPlacement) { case ToolbarPlacement.Top: target = topCommandBarArea; break; case ToolbarPlacement.Bottom: target = bottomCommandBarArea; break; case ToolbarPlacement.Default: default: target = Device.Idiom == TargetIdiom.Phone ? bottomCommandBarArea : topCommandBarArea; break; } if (current == null || target == null || current == target) { return; } // Remove the command bar from its current host and add it to the new one current.Child = null; target.Child = toolbar; }
public static IPlatformElementConfiguration <Android, FormsElement> SetToolbarPlacement(this IPlatformElementConfiguration <Android, FormsElement> config, ToolbarPlacement value) { SetToolbarPlacement(config.Element, value); return(config); }
public static IPlatformElementConfiguration <Windows, FormsElement> SetToolbarPlacement( this IPlatformElementConfiguration <Windows, FormsElement> config, ToolbarPlacement value) { config.Element.SetValue(ToolbarPlacementProperty, value); return(config); }
public static void SetToolbarPlacement(BindableObject element, ToolbarPlacement toolbarPlacement) { element.SetValue(ToolbarPlacementProperty, toolbarPlacement); }