protected override Span OnGetText(Cell cell, string part)
{
- TCell type1Cell = cell as TCell;
+ TCell type1Cell = (TCell)cell;
return new Span()
{
Text = type1Cell.Text,
{
if (part == IconPart)
{
- TCell typeCell = cell as TCell;
+ TCell typeCell = (TCell)cell;
var image = new NImage(TForms.Context.MainWindow);
+ image.IsFixedAspect = !typeCell.FillItem;
var task = image.LoadFromImageSourceAsync(ImageSource.FromFile(typeCell.Content));
return image;
}
if (part == EndPart)
{
- TCell typeCell = cell as TCell;
+ TCell typeCell = (TCell)cell;
if (typeCell.IsBadgeVisible)
{
var badge = new ElmSharp.Layout(TForms.Context.MainWindow);
}
else if (property == TypeGridViewCell.BadgeCountProperty.PropertyName || property == TypeGridViewCell.IsBadgeVisibleProperty.PropertyName)
{
- var typeCell = cell as TCell;
+ var typeCell = (TCell)cell;
EvasObject badge;
realizedView.TryGetValue(EndPart, out badge);
if (badge == null)
else if (property == TypeGridViewCell.ContentProperty.PropertyName)
{
EvasObject img;
- var typeCell = cell as TCell;
+ var typeCell = (TCell)cell;
realizedView.TryGetValue(IconPart, out img);
(img as NImage)?.LoadFromImageSourceAsync(typeCell.Content);
return false;
}
+ else if (property == TypeGridViewCell.FillItemProperty.PropertyName)
+ {
+ EvasObject img;
+ var typeCell = (TCell)cell;
+ realizedView.TryGetValue(IconPart, out img);
+ var nativeImg = img as NImage;
+ if (nativeImg != null)
+ nativeImg.IsFixedAspect = !typeCell.FillItem;
+ return false;
+ }
return false;
}
}
{
}
}
-
}
\ No newline at end of file
RegisterPropertyHandler(GridView.SelectionModeProperty, UpdateSelectionMode);
RegisterPropertyHandler(GridView.CanSelectionMultipleProperty, UpdateSelectionMultiple);
RegisterPropertyHandler(GridView.IsHighlightEffectEnabledProperty, UpdateHighlight);
- RegisterPropertyHandler(GridView.FillItemsProperty, UpdateFillItem);
RegisterPropertyHandler(GridView.OrientationProperty, UpdateOrientation);
RegisterPropertyHandler(GridView.ItemsSourceProperty, UpdateSource);
RegisterPropertyHandler(GridView.ScrollBarVisiblePolicyProperty, UpdateScrollBarVisiblePolicy);
Control.IsHighlight = Element.IsHighlightEffectEnabled;
}
- void UpdateFillItem()
- {
- Control.FillItems = Element.FillItems;
- }
-
void UpdateOrientation()
{
Control.IsHorizontal = (Element.Orientation == GridViewOrientation.Horizontal);
/// </remarks>
public abstract class TypeGridViewCell : Cell, IGridVeiwCell
{
- public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(GridViewCell), "");
+ public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(TypeGridViewCell), "");
- public static readonly BindableProperty ContentProperty = BindableProperty.Create("Content", typeof(string), typeof(GridViewCell), "");
+ public static readonly BindableProperty ContentProperty = BindableProperty.Create("Content", typeof(string), typeof(TypeGridViewCell), "");
- public static readonly BindableProperty IsBadgeVisibleProperty = BindableProperty.Create("IsBadgeVisible", typeof(bool), typeof(GridViewCell), false);
+ public static readonly BindableProperty IsBadgeVisibleProperty = BindableProperty.Create("IsBadgeVisible", typeof(bool), typeof(TypeGridViewCell), false);
- public static readonly BindableProperty BadgeCountProperty = BindableProperty.Create("BadgeCount", typeof(int), typeof(GridViewCell), default(int));
+ public static readonly BindableProperty BadgeCountProperty = BindableProperty.Create("BadgeCount", typeof(int), typeof(TypeGridViewCell), default(int));
+
+ public static readonly BindableProperty FillItemProperty = BindableProperty.Create("FillItem", typeof(bool), typeof(TypeGridViewCell), false);
/// <summary>
/// Gets or sets the the Text displayed as the content of Item.
get { return (int)GetValue(BadgeCountProperty); }
set { SetValue(BadgeCountProperty, value); }
}
+
+ /// <summary>
+ /// Gets or sets a value to indicate whether the content fill to the item.
+ /// </summary>
+ public bool FillItem
+ {
+ get { return (bool)GetValue(FillItemProperty); }
+ set { SetValue(FillItemProperty, value); }
+ }
}
+
/// <summary>
/// Type1GridViewCell is a class inherited from a TypeGridViewCell.
/// </summary>
public static readonly BindableProperty IsHighlightEffectEnabledProperty = BindableProperty.Create("IsHighlight", typeof(bool), typeof(GridView), true);
/// <summary>
- /// BindableProperty. Identifies the FillItems bindable property.
- /// </summary>
- public static readonly BindableProperty FillItemsProperty = BindableProperty.Create("FillItems", typeof(bool), typeof(GridView), default(bool));
-
- /// <summary>
/// BindableProperty. Identifies the Orientation bindable property.
/// </summary>
public static readonly BindableProperty OrientationProperty = BindableProperty.Create("Orientation", typeof(GridViewOrientation), typeof(GridView), GridViewOrientation.Vertical);
}
/// <summary>
- /// Gets or sets a value that indicates whether the content fills the area for item.
- /// By default, this value is false, the item's grid is not filled and the content is centered with the alignment.
- /// </summary>
- public bool FillItems
- {
- get { return (bool)GetValue(FillItemsProperty); }
- set { SetValue(FillItemsProperty, value); }
- }
-
- /// <summary>
/// Gets or sets a value that indicates whether the multiple selection is allowed.
/// By default, the value is false.
/// </summary>