using TForms = Xamarin.Forms.Platform.Tizen.Forms;
[assembly: ExportRenderer(typeof(GridView), typeof(GridViewRenderer))]
+
namespace Tizen.Xamarin.Forms.Extension.Renderer
{
class GridViewRenderer : ViewRenderer<GridView, GenGrid>, IDisposable
_scrollToRequested = OnScrollToRequested;
_collectionChanged = OnCollectionChanged;
- RegisterPropertyHandler(GridView.ColumnSpacingProperty, UpdateColumnSpacing);
- RegisterPropertyHandler(GridView.RowSpacingProperty, UpdateRowSpacing);
RegisterPropertyHandler(GridView.ItemHeightProperty, UpdateItemHeight);
RegisterPropertyHandler(GridView.ItemWidthProperty, UpdateItemWidth);
RegisterPropertyHandler(GridView.SelectionModeProperty, UpdateSelectionMode);
base.OnElementChanged(e);
}
- void UpdateColumnSpacing()
- {
- Control.WeightY = Element.ColumnSpacing;
- }
-
- void UpdateRowSpacing()
- {
- Control.WeightX = Element.RowSpacing;
- }
-
void UpdateItemHeight()
{
if (Element.ItemHeight < 0)
case GridViewSelectionMode.Default:
Control.SelectionMode = GenGridSelectionMode.Default;
break;
+
case GridViewSelectionMode.Always:
Control.SelectionMode = GenGridSelectionMode.Always;
break;
+
case GridViewSelectionMode.DisplayOnly:
Control.SelectionMode = GenGridSelectionMode.DisplayOnly;
break;
+
case GridViewSelectionMode.None:
Control.SelectionMode = GenGridSelectionMode.None;
break;
}
}
}
-}
-
+}
\ No newline at end of file
/// </summary>
/// <example>
/// <code>
- /// public class MyObject
+ /// public class MyObject : BindableObject
/// {
- /// public string Text { get; set; }
- /// public string ImagePath { get; set; }
- /// public bool IsBadgeVisible { get; set; }
- /// public int Count { get; set; }
+ /// public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(MyObject), "");
+ /// public static readonly BindableProperty ImagePathProperty = BindableProperty.Create("ImagePath", typeof(string), typeof(MyObject), "");
+ /// public static readonly BindableProperty IsBadgeVisibleProperty = BindableProperty.Create("IsBadgeVisible", typeof(bool), typeof(MyObject), false);
+ /// public static readonly BindableProperty CountProperty = BindableProperty.Create("Count", typeof(int), typeof(MyObject), 0);
+ /// public string Text
+ /// {
+ /// get { return (string)GetValue(TextProperty); }
+ /// set { SetValue(TextProperty, value); }
+ /// }
+ /// public string ImagePath
+ /// {
+ /// get { return (string)GetValue(ImagePathProperty); }
+ /// set { SetValue(ImagePathProperty, value); }
+ /// }
+ /// public bool IsBadgeVisible
+ /// {
+ /// get { return (bool)GetValue(IsBadgeVisibleProperty); }
+ /// set { SetValue(IsBadgeVisibleProperty, value); }
+ /// }
+ /// public int Count
+ /// {
+ /// get { return (int)GetValue(CountProperty); }
+ /// set { SetValue(CountProperty, value); }
+ /// }
/// }
/// public class GridViewTest : ContentPage
/// {
/// List<MyObject> MyData = new List<MyObject>();
/// for (int i = 0; i < 50; i++)
/// {
- /// MyData.Add(new MyObject { Text = "AAAA", ImagePath = "1.png", IsBadgeVisible = false, Count = 0);
- /// MyData.Add(new MyObject { Text = "BBBB", ImagePath = "1.png", IsBadgeVisible = false, Count = 0);
- /// MyData.Add(new MyObject { Text = "CCCC", ImagePath = "1.png", IsBadgeVisible = false, Count = 0);
- /// MyData.Add(new MyObject { Text = "DDDD", ImagePath = "1.png", IsBadgeVisible = false, Count = 0);
+ /// MyData.Add(new MyObject { Text = "AAAA", ImagePath = "1.png", IsBadgeVisible = false, Count = 0 });
+ /// MyData.Add(new MyObject { Text = "BBBB", ImagePath = "1.png", IsBadgeVisible = false, Count = 0 });
+ /// MyData.Add(new MyObject { Text = "CCCC", ImagePath = "1.png", IsBadgeVisible = false, Count = 0 });
+ /// MyData.Add(new MyObject { Text = "DDDD", ImagePath = "1.png", IsBadgeVisible = false, Count = 0 });
/// }
/// GridView view = new GridView
/// {
- /// ItemColumn = new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) },
- /// ItemRow = new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) },
+ /// ItemWidth = 150,
+ /// ItemHeight = 150,
/// SelectionMode = GridViewSelectionMode.Default,
/// CanSelectMultiple = true,
/// IsHighlightEffectEnabled = true,
- /// ColumnSpacing = 0.5,
- /// RowSpacing = 0.5,
/// ItemsSource = MyData,
/// ItemTemplate = new DataTemplate(() =>
/// {
const int DefaultItemWidth = -1;
const int DefaultItemHeight = -1;
- public static readonly BindableProperty ColumnSpacingProperty = BindableProperty.Create("ColumnSpacing", typeof(double), typeof(GridView), default(double));
-
- public static readonly BindableProperty RowSpacingProperty = BindableProperty.Create("RowSpacing", typeof(double), typeof(GridView), default(double));
-
public static readonly BindableProperty ItemHeightProperty = BindableProperty.Create("ItemHeight", typeof(int), typeof(GridView), DefaultItemHeight);
public static readonly BindableProperty ItemWidthProperty = BindableProperty.Create("ItemWidth", typeof(int), typeof(GridView), DefaultItemWidth);
}
/// <summary>
- /// Gets or sets colum spacing of the GridView.
- /// </summary>
- public double ColumnSpacing
- {
- get { return (double)GetValue(ColumnSpacingProperty); }
- set { SetValue(ColumnSpacingProperty, value); }
- }
-
- /// <summary>
- /// Gets or sets row spacing of the GridView.
- /// </summary>
- public double RowSpacing
- {
- get { return (double)GetValue(RowSpacingProperty); }
- set { SetValue(RowSpacingProperty, value); }
- }
-
- /// <summary>
/// Gets or sets select mode.
/// </summary>
public GridViewSelectionMode SelectionMode