summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WP8/TextCellRenderer.cs
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-03-22 20:02:25 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-03-22 23:13:41 (GMT)
commit17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch)
treeb5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Platform.WP8/TextCellRenderer.cs
downloadxamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2
Initial import
Diffstat (limited to 'Xamarin.Forms.Platform.WP8/TextCellRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.WP8/TextCellRenderer.cs88
1 files changed, 88 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WP8/TextCellRenderer.cs b/Xamarin.Forms.Platform.WP8/TextCellRenderer.cs
new file mode 100644
index 0000000..b3c2453
--- /dev/null
+++ b/Xamarin.Forms.Platform.WP8/TextCellRenderer.cs
@@ -0,0 +1,88 @@
+´╗┐using System;
+using System.Windows.Input;
+using Microsoft.Phone.Controls;
+
+namespace Xamarin.Forms.Platform.WinPhone
+{
+ public class TextCellRenderer : ICellRenderer
+ {
+ public virtual System.Windows.DataTemplate GetTemplate(Cell cell)
+ {
+ if (cell.RealParent is ListView)
+ {
+ if (TemplatedItemsList<ItemsView<Cell>, Cell>.GetIsGroupHeader(cell))
+ return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["ListViewHeaderTextCell"];
+
+ return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["ListViewTextCell"];
+ }
+
+ return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["TextCell"];
+ }
+ }
+
+ public class EntryCellRendererCompleted : ICommand
+ {
+ public bool CanExecute(object parameter)
+ {
+ return true;
+ }
+
+ public event EventHandler CanExecuteChanged;
+
+ public void Execute(object parameter)
+ {
+ var entryCell = (EntryCell)parameter;
+ entryCell.SendCompleted();
+ }
+ }
+
+ public class EntryCellPhoneTextBox : PhoneTextBox
+ {
+ public event EventHandler KeyboardReturnPressed;
+
+ protected override void OnKeyUp(KeyEventArgs e)
+ {
+ if (e.Key == Key.Enter)
+ {
+ EventHandler handler = KeyboardReturnPressed;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+ base.OnKeyUp(e);
+ }
+ }
+
+ public class EntryCellRenderer : ICellRenderer
+ {
+ public virtual System.Windows.DataTemplate GetTemplate(Cell cell)
+ {
+ return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["EntryCell"];
+ }
+ }
+
+ public class ViewCellRenderer : ICellRenderer
+ {
+ public virtual System.Windows.DataTemplate GetTemplate(Cell cell)
+ {
+ return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["ViewCell"];
+ }
+ }
+
+ public class SwitchCellRenderer : ICellRenderer
+ {
+ public virtual System.Windows.DataTemplate GetTemplate(Cell cell)
+ {
+ return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["SwitchCell"];
+ }
+ }
+
+ public class ImageCellRenderer : ICellRenderer
+ {
+ public virtual System.Windows.DataTemplate GetTemplate(Cell cell)
+ {
+ if (cell.RealParent is ListView)
+ return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["ListImageCell"];
+ return (System.Windows.DataTemplate)System.Windows.Application.Current.Resources["ImageCell"];
+ }
+ }
+} \ No newline at end of file