blob: 24feecbc3d2944a810c0423b66c0b780a8e2a4cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
using Windows.UI.Xaml.Controls;
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
namespace Xamarin.Forms.Platform.UWP
{
internal class ToolbarPlacementHelper
{
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;
}
}
}
|