Merge pull request #206 from zumero/listview-separator
Ooui.Forms ListView Separators
This commit is contained in:
commit
7d3a985e01
|
@ -41,6 +41,7 @@ namespace Ooui.Forms.Renderers
|
|||
e.NewElement.ScrollToRequested += ListView_ScrollToRequested;
|
||||
|
||||
UpdateItems ();
|
||||
UpdateSeparator ();
|
||||
UpdateBackgroundColor ();
|
||||
}
|
||||
|
||||
|
@ -53,6 +54,10 @@ namespace Ooui.Forms.Renderers
|
|||
|
||||
if (e.PropertyName == ItemsView<Cell>.ItemsSourceProperty.PropertyName)
|
||||
UpdateItems ();
|
||||
else if (e.PropertyName == Xamarin.Forms.ListView.SeparatorColorProperty.PropertyName)
|
||||
UpdateSeparator ();
|
||||
else if (e.PropertyName == Xamarin.Forms.ListView.SeparatorVisibilityProperty.PropertyName)
|
||||
UpdateSeparator ();
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
|
@ -76,6 +81,7 @@ namespace Ooui.Forms.Renderers
|
|||
private void OnCollectionChanged (object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
UpdateItems ();
|
||||
UpdateSeparator ();
|
||||
}
|
||||
|
||||
private void UnsubscribeCellClicks ()
|
||||
|
@ -134,6 +140,27 @@ namespace Ooui.Forms.Renderers
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateSeparator()
|
||||
{
|
||||
if (Control == null)
|
||||
return;
|
||||
|
||||
var listItems = Control.Children.OfType<ListItem>().ToList();
|
||||
|
||||
foreach (var li in listItems)
|
||||
{
|
||||
if (Element.SeparatorVisibility == SeparatorVisibility.Default)
|
||||
{
|
||||
var color = Element.SeparatorColor.ToOouiColor(Color.FromStyleValue("#999"));
|
||||
li.Style["border-bottom"] = string.Format("{0}px {1} {2}", 1, "solid", color.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
li.Style["border-bottom"] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ListItem_Click (object sender, TargetEventArgs e)
|
||||
{
|
||||
if (Control == null)
|
||||
|
|
Loading…
Reference in New Issue