Skip to content
This repository has been archived by the owner on Aug 29, 2019. It is now read-only.

Commit

Permalink
性能改进
Browse files Browse the repository at this point in the history
增加一些常用功能
  • Loading branch information
yinyue200 committed Jul 13, 2017
1 parent 7dd87a8 commit 5ef23c2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion PicotPage.Android/Renderer/ViewPanelRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class CustomPagerAdapter : PagerAdapter
{
private ViewPanel _customViewPage;
private Context _context;
private IList _views = new List< Xamarin.Forms.View>();
private IList<Xamarin.Forms.View> _views = new List<Xamarin.Forms.View>();
public CustomPagerAdapter(Context context, ViewPanel customViewPage)
{
_customViewPage = customViewPage;
Expand Down
20 changes: 16 additions & 4 deletions PivotView/PivotPagePortable/Pivot/PivotPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ public PivotPage()
_viewPanel.SelectChanged += _viewPanel_SelectChanged;
}

public event EventHandler<SelectedPositionChangedEventArgs> MainViewChanged;

public int MainViewIndex
{
get
{
return _viewPanel.CurrentIndex;
}
}

private void _viewPanel_SelectChanged(object sender, SelectedPositionChangedEventArgs e)
{
var index = (int)e.SelectedPosition;
Expand All @@ -54,6 +64,8 @@ private void _viewPanel_SelectChanged(object sender, SelectedPositionChangedEven
{
_headerList.SelectedIndex = index;
}

MainViewChanged?.Invoke(this, new SelectedPositionChangedEventArgs(MainViewIndex));
}

private void headerList_ItemSelected(object sender, SelectedItemChangedEventArgs e)
Expand Down Expand Up @@ -124,17 +136,17 @@ static void OnHeadersPropertyChnaged(BindableObject sender, object oldValue, obj
/// <summary>
/// PivotPage第二组成部分Views
/// </summary>
public static readonly BindableProperty ViewsProperty = BindableProperty.Create("Views", typeof(IEnumerable), typeof(PivotPage), null, propertyChanged: OnViewsPropertyChnaged);
public IEnumerable<View> Views
public static readonly BindableProperty ViewsProperty = BindableProperty.Create(nameof(Views), typeof(IList<View>), typeof(PivotPage), null, propertyChanged: OnViewsPropertyChnaged);
public IList<View> Views
{
get { return (IEnumerable<View>)this.GetValue(ViewsProperty); }
get { return (IList<View>)this.GetValue(ViewsProperty); }
set { SetValue(ViewsProperty, value); }
}

static void OnViewsPropertyChnaged(BindableObject sender, object oldValue, object newValue)
{
var pivot = sender as PivotPage;
pivot._viewPanel.PanelChildren = (IEnumerable<View>)newValue;
pivot._viewPanel.PanelChildren = (IList<View>)newValue;
}
}
}
8 changes: 4 additions & 4 deletions PivotView/PivotPagePortable/Pivot/ViewPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public ViewPanel()
/// <summary>
/// 支持数据绑定的Child View集合
/// </summary>
public static readonly BindableProperty ChildrenProperty = BindableProperty.Create(nameof(PanelChildren), typeof(IEnumerable<View>), typeof(ViewPanel), propertyChanged: OnChildrenChanged);
public IEnumerable<View> PanelChildren
public static readonly BindableProperty ChildrenProperty = BindableProperty.Create(nameof(PanelChildren), typeof(IList<View>), typeof(ViewPanel), propertyChanged: OnChildrenChanged);
public IList<View> PanelChildren
{
get { return (IEnumerable<View>)this.GetValue(ChildrenProperty); }
get { return (IList<View>)this.GetValue(ChildrenProperty); }
set { SetValue(ChildrenProperty, value); }
}
/// <summary>
Expand Down Expand Up @@ -105,7 +105,7 @@ protected override void LayoutChildren(double x, double y, double width, double
}

public event EventHandler<SelectedPositionChangedEventArgs> SelectChanged;
public static readonly BindableProperty CurrentIndexProperty = BindableProperty.Create("CurrentIndex", typeof(int), typeof(ViewPanel), 0);
public static readonly BindableProperty CurrentIndexProperty = BindableProperty.Create(nameof(CurrentIndex), typeof(int), typeof(ViewPanel), 0);
public int CurrentIndex
{
get { return (int)this.GetValue(CurrentIndexProperty); }
Expand Down

0 comments on commit 5ef23c2

Please sign in to comment.