/// <summary> /// Set focus to item which has specific data index. /// </summary> /// <param name="dataIndex">Data index of item.</param> /// <param name="animated">If set true, scroll to item using animation.</param> /// <since_tizen> 8 </since_tizen> /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API public void SetFocus(int dataIndex, bool animated) { foreach (RecycleItem item in Children) { if (item.DataIndex == dataIndex) { RecycleItem prevFocusedItem = FocusedItem; prevFocusedItem?.OnFocusLost(); FocusedItem = item; FocusedItem.OnFocusGained(); ScrollTo(item.DataIndex * mLayoutManager.StepSize, animated); } } }
/// <summary> /// This helps developer who wants to know before scroll is reaching target position. /// </summary> /// <param name="targetPosition">Index of item.</param> /// <since_tizen> 8 </since_tizen> /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API protected override void OnPreReachedTargetPosition(float targetPosition) { int targetDataIndex = (int)Math.Round(Math.Abs(targetPosition) / mLayoutManager.StepSize); for (int i = 0; i < Children.Count; i++) { RecycleItem item = Children[i] as RecycleItem; if (targetDataIndex == item.DataIndex) { FocusedItem = item; item.OnFocusGained(); break; } } }