summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WP8
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-06-17 03:10:18 -0700
committerRui Marinho <me@ruimarinho.net>2016-06-17 11:10:18 +0100
commit925fc0aa588a060eb23fa16c1d225dd030012c23 (patch)
tree83676c25c29d97d9250516b217020ba85425796d /Xamarin.Forms.Platform.WP8
parentd44396a4534b1e2bc81143c809e4adaee656ab15 (diff)
downloadxamarin-forms-925fc0aa588a060eb23fa16c1d225dd030012c23.tar.gz
xamarin-forms-925fc0aa588a060eb23fa16c1d225dd030012c23.tar.bz2
xamarin-forms-925fc0aa588a060eb23fa16c1d225dd030012c23.zip
Prep Cell & friends for removal of InternalsVisibleTo (#142)
* Prep Cell & friends for removal of InternalsVisibleTo Includes: - Cell - EntryCell - ListView - MenuItem - TableView - ViewCell - Toolbar Moved extensions to Internal & removed TPH * Update docs * [Controls] Ignore Issue2411 on iOS <9 * [Controls] Formatting for Issue2411
Diffstat (limited to 'Xamarin.Forms.Platform.WP8')
-rw-r--r--Xamarin.Forms.Platform.WP8/CarouselPageRenderer.cs1
-rw-r--r--Xamarin.Forms.Platform.WP8/CellControl.cs7
-rw-r--r--Xamarin.Forms.Platform.WP8/CellTemplateSelector.cs7
-rw-r--r--Xamarin.Forms.Platform.WP8/CustomContextMenu.cs2
-rw-r--r--Xamarin.Forms.Platform.WP8/ListViewRenderer.cs47
-rw-r--r--Xamarin.Forms.Platform.WP8/Platform.cs16
-rw-r--r--Xamarin.Forms.Platform.WP8/TableViewRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.WP8/TextCellRenderer.cs5
8 files changed, 53 insertions, 39 deletions
diff --git a/Xamarin.Forms.Platform.WP8/CarouselPageRenderer.cs b/Xamarin.Forms.Platform.WP8/CarouselPageRenderer.cs
index 26cf2c1f..d5e20847 100644
--- a/Xamarin.Forms.Platform.WP8/CarouselPageRenderer.cs
+++ b/Xamarin.Forms.Platform.WP8/CarouselPageRenderer.cs
@@ -6,6 +6,7 @@ using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Phone.Controls;
+using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Platform.WinPhone
{
diff --git a/Xamarin.Forms.Platform.WP8/CellControl.cs b/Xamarin.Forms.Platform.WP8/CellControl.cs
index 0f3eb463..92da82a4 100644
--- a/Xamarin.Forms.Platform.WP8/CellControl.cs
+++ b/Xamarin.Forms.Platform.WP8/CellControl.cs
@@ -3,6 +3,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Microsoft.Phone.Controls;
+using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Platform.WinPhone
{
@@ -19,7 +20,7 @@ namespace Xamarin.Forms.Platform.WinPhone
{
Unloaded += (sender, args) =>
{
- var cell = DataContext as Cell;
+ var cell = DataContext as ICellController;
if (cell != null)
cell.SendDisappearing();
};
@@ -56,12 +57,12 @@ namespace Xamarin.Forms.Platform.WinPhone
if (oldCell != null)
{
oldCell.PropertyChanged -= _propertyChangedHandler;
- oldCell.SendDisappearing();
+ ((ICellController)oldCell).SendDisappearing();
}
if (newCell != null)
{
- newCell.SendAppearing();
+ ((ICellController)newCell).SendAppearing();
if (oldCell == null || oldCell.GetType() != newCell.GetType())
ContentTemplate = GetTemplate(newCell);
diff --git a/Xamarin.Forms.Platform.WP8/CellTemplateSelector.cs b/Xamarin.Forms.Platform.WP8/CellTemplateSelector.cs
index 09d939fd..42e66fb1 100644
--- a/Xamarin.Forms.Platform.WP8/CellTemplateSelector.cs
+++ b/Xamarin.Forms.Platform.WP8/CellTemplateSelector.cs
@@ -1,6 +1,7 @@
´╗┐using System;
using System.Globalization;
using System.Windows;
+using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Platform.WinPhone
{
@@ -29,7 +30,7 @@ namespace Xamarin.Forms.Platform.WinPhone
Loaded += (sender, args) => SetBinding(SourceProperty, new System.Windows.Data.Binding());
Unloaded += (sender, args) =>
{
- var cell = DataContext as Cell;
+ var cell = DataContext as ICellController;
if (cell != null)
cell.SendDisappearing();
};
@@ -47,8 +48,8 @@ namespace Xamarin.Forms.Platform.WinPhone
void SetSource(object oldSource, object newSource)
{
- var oldCell = oldSource as Cell;
- var newCell = newSource as Cell;
+ var oldCell = oldSource as ICellController;
+ var newCell = newSource as ICellController;
if (oldCell != null)
oldCell.SendDisappearing();
diff --git a/Xamarin.Forms.Platform.WP8/CustomContextMenu.cs b/Xamarin.Forms.Platform.WP8/CustomContextMenu.cs
index 4946b2b2..faf9cb81 100644
--- a/Xamarin.Forms.Platform.WP8/CustomContextMenu.cs
+++ b/Xamarin.Forms.Platform.WP8/CustomContextMenu.cs
@@ -19,7 +19,7 @@ namespace Xamarin.Forms.Platform.WinPhone
var menuItem = item.DataContext as MenuItem;
if (menuItem != null)
- menuItem.Activate();
+ ((IMenuItemController)menuItem).Activate();
};
return item;
}
diff --git a/Xamarin.Forms.Platform.WP8/ListViewRenderer.cs b/Xamarin.Forms.Platform.WP8/ListViewRenderer.cs
index e505526b..538c529f 100644
--- a/Xamarin.Forms.Platform.WP8/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.WP8/ListViewRenderer.cs
@@ -11,6 +11,8 @@ using Microsoft.Phone.Controls;
using GestureEventArgs = System.Windows.Input.GestureEventArgs;
using SLButton = System.Windows.Controls.Button;
using SLBinding = System.Windows.Data.Binding;
+using System.Collections;
+using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Platform.WinPhone
{
@@ -192,6 +194,8 @@ namespace Xamarin.Forms.Platform.WinPhone
System.Windows.Controls.ProgressBar _progressBar;
ViewportControl _viewport;
+ IListViewController Controller => Element;
+ ITemplatedItemsView<Cell> TemplatedItemsView => Element;
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
@@ -224,7 +228,7 @@ namespace Xamarin.Forms.Platform.WinPhone
{
base.OnElementChanged(e);
- Element.ScrollToRequested += OnScrollToRequested;
+ Controller.ScrollToRequested += OnScrollToRequested;
if (Element.SelectedItem != null)
_itemNeedsSelecting = true;
@@ -232,7 +236,7 @@ namespace Xamarin.Forms.Platform.WinPhone
_listBox = new FixedLongListSelector
{
DataContext = Element,
- ItemsSource = Element.TemplatedItems,
+ ItemsSource = (IList)TemplatedItemsView.TemplatedItems,
ItemTemplate = (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["CellTemplate"],
GroupHeaderTemplate = (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["ListViewHeader"],
ListHeaderTemplate = (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["View"],
@@ -461,18 +465,17 @@ namespace Xamarin.Forms.Platform.WinPhone
if (Element.IsGroupingEnabled)
{
- TemplatedItemsList<ItemsView<Cell>, Cell> til = TemplatedItemsList<ItemsView<Cell>, Cell>.GetGroup(cell);
- parentCell = til.HeaderContent;
+ parentCell = cell.GetGroupHeaderContent<ItemsView<Cell>, Cell>();
}
_fromNative = cell.BindingContext;
if (Element.IsGroupingEnabled)
{
- Element.NotifyRowTapped(TemplatedItemsList<ItemsView<Cell>, Cell>.GetIndex(parentCell), TemplatedItemsList<ItemsView<Cell>, Cell>.GetIndex(cell));
+ Controller.NotifyRowTapped(parentCell.GetIndex<ItemsView<Cell>, Cell>(), cell.GetIndex<ItemsView<Cell>, Cell>(), null);
}
else
- Element.NotifyRowTapped(TemplatedItemsList<ItemsView<Cell>, Cell>.GetIndex(cell));
+ Controller.NotifyRowTapped(cell.GetIndex<ItemsView<Cell>, Cell>(), null);
}
void OnNativeSelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -496,22 +499,22 @@ namespace Xamarin.Forms.Platform.WinPhone
void OnPullToRefreshCanceled(object sender, EventArgs args)
{
- if (Element.IsPullToRefreshEnabled && ((IListViewController)Element).RefreshAllowed)
+ if (Element.IsPullToRefreshEnabled && Controller.RefreshAllowed)
_progressBar.Visibility = Visibility.Collapsed;
}
void OnPullToRefreshCompleted(object sender, EventArgs args)
{
- if (Element.IsPullToRefreshEnabled && ((IListViewController)Element).RefreshAllowed)
+ if (Element.IsPullToRefreshEnabled && Controller.RefreshAllowed)
{
_progressBar.IsIndeterminate = true;
- ((IListViewController)Element).SendRefreshing();
+ Controller.SendRefreshing();
}
}
void OnPullToRefreshStarted(object sender, EventArgs args)
{
- if (Element.IsPullToRefreshEnabled && ((IListViewController)Element).RefreshAllowed)
+ if (Element.IsPullToRefreshEnabled && Controller.RefreshAllowed)
{
_progressBar.Visibility = Visibility.Visible;
_progressBar.IsIndeterminate = false;
@@ -521,7 +524,7 @@ namespace Xamarin.Forms.Platform.WinPhone
void OnPullToRefreshStatusUpdated(object sender, EventArgs eventArgs)
{
- if (Element.IsPullToRefreshEnabled && ((IListViewController)Element).RefreshAllowed)
+ if (Element.IsPullToRefreshEnabled && Controller.RefreshAllowed)
_progressBar.Value = Math.Max(0, Math.Min(1, _listBox.PullToRefreshStatus));
}
@@ -567,28 +570,30 @@ namespace Xamarin.Forms.Platform.WinPhone
double targetHeaderHeight = 0;
var templateReusables = new Dictionary<System.Windows.DataTemplate, FrameworkElement>();
+ var templatedItems = TemplatedItemsView.TemplatedItems;
+ var scrollArgs = (ITemplatedItemsListScrollToRequestedEventArgs)e;
var found = false;
if (Element.IsGroupingEnabled)
{
- for (var g = 0; g < Element.TemplatedItems.Count; g++)
+ for (var g = 0; g < templatedItems.Count; g++)
{
if (found)
break;
- TemplatedItemsList<ItemsView<Cell>, Cell> til = Element.TemplatedItems.GetGroup(g);
+ var til = templatedItems.GetGroup(g);
double headerHeight = GetHeight(templateReusables, Control.GroupHeaderTemplate, til);
y += headerHeight;
for (var i = 0; i < til.Count; i++)
{
- Cell cell = til[i];
+ Cell cell = til[i] as Cell;
double contentHeight = GetHeight(templateReusables, Control.ItemTemplate, cell);
- if ((ReferenceEquals(til.BindingContext, e.Group) || e.Group == null) && ReferenceEquals(cell.BindingContext, e.Item))
+ if ((ReferenceEquals(til.BindingContext, scrollArgs.Group) || scrollArgs.Group == null) && ReferenceEquals(cell.BindingContext, scrollArgs.Item))
{
targetHeaderHeight = headerHeight;
targetHeight = contentHeight;
@@ -602,13 +607,13 @@ namespace Xamarin.Forms.Platform.WinPhone
}
else
{
- for (var i = 0; i < Element.TemplatedItems.Count; i++)
+ for (var i = 0; i < templatedItems.Count; i++)
{
- Cell cell = Element.TemplatedItems[i];
+ Cell cell = templatedItems[i] as Cell;
double height = GetHeight(templateReusables, Control.ItemTemplate, cell);
- if (ReferenceEquals(cell.BindingContext, e.Item))
+ if (ReferenceEquals(cell.BindingContext, scrollArgs.Item))
{
found = true;
targetHeight = height;
@@ -683,12 +688,12 @@ namespace Xamarin.Forms.Platform.WinPhone
void UpdateFooter()
{
- Control.ListFooter = ((IListViewController)Element).FooterElement;
+ Control.ListFooter = Controller.FooterElement;
}
void UpdateHeader()
{
- Control.ListHeader = ((IListViewController)Element).HeaderElement;
+ Control.ListHeader = Controller.HeaderElement;
}
void UpdateIsRefreshing()
@@ -701,7 +706,7 @@ namespace Xamarin.Forms.Platform.WinPhone
else
{
_progressBar.IsIndeterminate = false;
- _progressBar.Visibility = _listBox.IsInPullToRefresh && Element.IsPullToRefreshEnabled && ((IListViewController)Element).RefreshAllowed ? Visibility.Visible : Visibility.Collapsed;
+ _progressBar.Visibility = _listBox.IsInPullToRefresh && Element.IsPullToRefreshEnabled && Controller.RefreshAllowed ? Visibility.Visible : Visibility.Collapsed;
}
}
diff --git a/Xamarin.Forms.Platform.WP8/Platform.cs b/Xamarin.Forms.Platform.WP8/Platform.cs
index 00623b4d..be71df09 100644
--- a/Xamarin.Forms.Platform.WP8/Platform.cs
+++ b/Xamarin.Forms.Platform.WP8/Platform.cs
@@ -7,6 +7,7 @@ using System.Windows;
using System.Windows.Controls;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
+using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Platform.WinPhone
{
@@ -536,6 +537,7 @@ namespace Xamarin.Forms.Platform.WinPhone
var buttonsToAdd = new List<TaggedAppBarButton>();
foreach (ToolbarItem item in items.Where(i => i.Order != ToolbarItemOrder.Secondary))
{
+ IMenuItemController controller = item;
if (_page.ApplicationBar.Buttons.OfType<TaggedAppBarButton>().Any(b => b.Tag == item))
continue;
@@ -543,10 +545,10 @@ namespace Xamarin.Forms.Platform.WinPhone
{
IconUri = new Uri(item.Icon ?? "ApplicationIcon.jpg", UriKind.Relative),
Text = !string.IsNullOrWhiteSpace(item.Text) ? item.Text : (string)item.Icon ?? "ApplicationIcon.jpg",
- IsEnabled = item.IsEnabled,
+ IsEnabled = controller.IsEnabled,
Tag = item
};
- button.Click += (sender, args) => item.Activate();
+ button.Click += (sender, args) => controller.Activate();
buttonsToAdd.Add(button);
}
@@ -557,7 +559,7 @@ namespace Xamarin.Forms.Platform.WinPhone
continue;
var button = new TaggedAppBarMenuItem { Text = !string.IsNullOrWhiteSpace(item.Text) ? item.Text : (string)item.Icon ?? "MenuItem", IsEnabled = true, Tag = item };
- button.Click += (sender, args) => item.Activate();
+ button.Click += (sender, args) => ((IMenuItemController)item).Activate();
menuItemsToAdd.Add(button);
}
@@ -565,7 +567,7 @@ namespace Xamarin.Forms.Platform.WinPhone
TaggedAppBarMenuItem[] deadMenuItems = _page.ApplicationBar.MenuItems.OfType<TaggedAppBarMenuItem>().Where(b => b.Tag is ToolbarItem && !items.Contains(b.Tag)).ToArray();
- // we must remove the dead buttons before adding the new ones so we dont accidentally go over the limit during the tranistion
+ // we must remove the dead buttons before adding the new ones so we don't accidentally go over the limit during the transition
foreach (TaggedAppBarButton deadButton in deadButtons)
{
deadButton.Dispose();
@@ -623,8 +625,10 @@ namespace Xamarin.Forms.Platform.WinPhone
if (item == null)
return;
- if (e.PropertyName == MenuItem.IsEnabledProperty.PropertyName)
- IsEnabled = item.IsEnabled;
+ IMenuItemController controller = item;
+
+ if (e.PropertyName == controller.IsEnabledPropertyName)
+ IsEnabled = controller.IsEnabled;
else if (e.PropertyName == MenuItem.TextProperty.PropertyName)
Text = !string.IsNullOrWhiteSpace(item.Text) ? item.Text : (string)item.Icon ?? "ApplicationIcon.jpg";
else if (e.PropertyName == MenuItem.IconProperty.PropertyName)
diff --git a/Xamarin.Forms.Platform.WP8/TableViewRenderer.cs b/Xamarin.Forms.Platform.WP8/TableViewRenderer.cs
index 84f205eb..4c685613 100644
--- a/Xamarin.Forms.Platform.WP8/TableViewRenderer.cs
+++ b/Xamarin.Forms.Platform.WP8/TableViewRenderer.cs
@@ -11,6 +11,7 @@ namespace Xamarin.Forms.Platform.WinPhone
public class TableViewRenderer : ViewRenderer<Xamarin.Forms.TableView, TableView>
{
TableView _view;
+ ITableViewController Controller => Element;
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
@@ -23,7 +24,7 @@ namespace Xamarin.Forms.Platform.WinPhone
{
base.OnElementChanged(e);
- Element.ModelChanged += OnModelChanged;
+ Controller.ModelChanged += OnModelChanged;
_view = new TableView { DataContext = Element.Root };
_view.Tap += OnTapTable;
@@ -71,7 +72,7 @@ namespace Xamarin.Forms.Platform.WinPhone
if (!FindIndices(e, out sectionIndex, out cellIndex))
return;
- Element.Model.RowLongPressed(sectionIndex, cellIndex);
+ Controller.Model.RowLongPressed(sectionIndex, cellIndex);
}
void OnModelChanged(object sender, EventArgs eventArgs)
@@ -85,7 +86,7 @@ namespace Xamarin.Forms.Platform.WinPhone
if (!FindIndices(e, out sectionIndex, out cellIndex))
return;
- Element.Model.RowSelected(sectionIndex, cellIndex);
+ Controller.Model.RowSelected(sectionIndex, cellIndex);
}
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.WP8/TextCellRenderer.cs b/Xamarin.Forms.Platform.WP8/TextCellRenderer.cs
index 56a9a389..3845ae4e 100644
--- a/Xamarin.Forms.Platform.WP8/TextCellRenderer.cs
+++ b/Xamarin.Forms.Platform.WP8/TextCellRenderer.cs
@@ -1,6 +1,7 @@
´╗┐using System;
using System.Windows.Input;
using Microsoft.Phone.Controls;
+using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Platform.WinPhone
{
@@ -10,7 +11,7 @@ namespace Xamarin.Forms.Platform.WinPhone
{
if (cell.RealParent is ListView)
{
- if (TemplatedItemsList<ItemsView<Cell>, Cell>.GetIsGroupHeader(cell))
+ if (cell.GetIsGroupHeader<ItemsView<Cell>, Cell>())
return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["ListViewHeaderTextCell"];
return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["ListViewTextCell"];
@@ -31,7 +32,7 @@ namespace Xamarin.Forms.Platform.WinPhone
public void Execute(object parameter)
{
- var entryCell = (EntryCell)parameter;
+ var entryCell = (IEntryCellController)parameter;
entryCell.SendCompleted();
}