MonoMobile.Views.DialogViewController.FinishSearch C# (CSharp) Method

FinishSearch() public method

Allows the caller to programatically stop searching.
public FinishSearch ( bool hide ) : void
hide bool
return void
		public virtual void FinishSearch(bool hide)
		{
			if (_Searchbar == null) return;
							
			if (_OriginalSections != null)
			{
				var index = 0;
				foreach(var section in _OriginalSections.Values)
				{
					var list = section.DataContext as IEnumerable;
					if (list != null)
					{
						section.DataContext = _OriginalDataContext[index++] as IList;
					}
				}
				((BaseDialogViewSource)TableView.Source).Sections = _OriginalSections;
				
				_OriginalSections = null;
				ReloadData();
			}
			
			if (hide)
			{
				UIView.BeginAnimations(null);
				UIView.SetAnimationDuration(0.3);
				
				// we need to perform some post operations after the animation is complete
				UIView.SetAnimationDelegate(this);
				UIView.SetAnimationDidStopSelector(new Selector("fadeOutDidFinish"));
				
				if (_Searchbar != null)
					_Searchbar.Frame = new RectangleF(0, -45, _Searchbar.Frame.Width, 45);
				
				TableView.ContentOffset = new PointF(0, 45);
				UIView.CommitAnimations();
			}

			_Searchbar.ResignFirstResponder();
			_Searchbar.Text = string.Empty;
		}
	

Usage Example

Beispiel #1
0
 public override void CancelButtonClicked(UISearchBar searchbar)
 {
     searchbar.ShowsCancelButton = false;
     searchbar.ResignFirstResponder();
     new Wait(TimeSpan.FromMilliseconds(300), () =>
     {
         _Container.FinishSearch(false);
         _Container.ToggleSearchbar();
     });
 }