public MainPage() { _suburbs = new ObservableCollection <Suburb>(); ListView lstView = new ListView(); lstView.RowHeight = 60; this.Title = "Suburbs"; lstView.ItemTemplate = new DataTemplate(typeof(CustomSuburbCell)); lstView.IsPullToRefreshEnabled = true; lstView.SetBinding(ListView.ItemsSourceProperty, new Binding("Suburbs")); var stack = new StackLayout() { Spacing = 10, Orientation = StackOrientation.Vertical }; var searchBar = new SearchBar() { Placeholder = "Search" }; searchBar.SetBinding(SearchBar.TextProperty, new Binding("Search")); searchBar.SetBinding(SearchBar.SearchCommandProperty, new Binding("FilterListCommand")); stack.Children.Add(searchBar); stack.Children.Add(lstView); Content = stack; }
public PhotoListPage() { searchBar = new SearchBar { Placeholder = "Enter search term", //SearchCommand = new Command(() => { Console.WriteLine($"Search command"); }) BackgroundColor = Color.Wheat, }; searchBar.SetBinding(SearchBar.SearchCommandProperty, nameof(ViewModel.SearchCommand)); searchBar.SetBinding(SearchBar.TextProperty, nameof(ViewModel.SearchString)); _addPhotosButton = new ToolbarItem { Text = "+", AutomationId = AutomationIdConstants.AddPhotoButton }; _addPhotosButton.Clicked += HandleAddContactButtonClicked; ToolbarItems.Add(_addPhotosButton); _photosListView = new ListView(ListViewCachingStrategy.RecycleElement) { ItemTemplate = new DataTemplate(typeof(PhotoViewCell)), IsPullToRefreshEnabled = true, BackgroundColor = Color.Transparent, AutomationId = AutomationIdConstants.PhotoListView, SeparatorVisibility = SeparatorVisibility.None }; _photosListView.ItemSelected += HandleItemSelected; _photosListView.SetBinding(ListView.IsRefreshingProperty, nameof(ViewModel.IsRefreshing)); _photosListView.SetBinding(ListView.ItemsSourceProperty, nameof(ViewModel.AllPhotosList)); _photosListView.SetBinding(ListView.RefreshCommandProperty, nameof(ViewModel.RefreshCommand)); //#TODO - modifying size of cells _photosListView.HasUnevenRows = true; Title = PageTitles.PhotoListPage; var stackLayout = new StackLayout(); stackLayout.Children.Add(searchBar); stackLayout.Children.Add(_photosListView); var relativeLayout = new RelativeLayout(); //relativeLayout.Children.Add(searchBar, _photosListView, relativeLayout.Children.Add(stackLayout, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent(parent => parent.Width), Constraint.RelativeToParent(parent => parent.Height)); Content = relativeLayout; }
public NotificationsPage() { BindingContext = App.Locator.Notification; _viewModel = BindingContext as NotificationsViewModel; _notificationSearchBar = new SearchBar() { }; _notificationSearchBar.SetBinding(SearchBar.TextProperty,"TEXT"); _notificationSearchBar.SetBinding(SearchBar.SearchCommandProperty,"SearchCommand" ); }
public void SetupSearchbar(SearchBarViewModel searchBar) { _searchBar.SetBinding(IsVisibleProperty, "ShowSearchBar"); _searchBar.SetBinding(SearchBar.PlaceholderProperty, "SearchBar.PlaceholderText"); if (RedbridgeThemeManager.HasTheme) { //_searchBar.PlaceholderColor = RedbridgeThemeManager.Current.TintColour; _searchBar.CancelButtonColor = RedbridgeThemeManager.Current.TintColour; } else { _searchBar.SetBinding(SearchBar.PlaceholderColorProperty, "SearchBar.PlaceholderTextColor"); _searchBar.SetBinding(SearchBar.CancelButtonColorProperty, "SearchBar.CancelButtonColor"); } }
public SearchBarCodeMvvmPage() { Title = "Code MVVM SearchBar"; Padding = 10; BindingContext = new SearchViewModel(); SearchBar searchBar = new SearchBar { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.CenterAndExpand, Placeholder = "Search fruits...", }; searchBar.SetBinding(SearchBar.SearchCommandProperty, "PerformSearch"); searchBar.SetBinding(SearchBar.SearchCommandParameterProperty, new Binding { Source = searchBar, Path = "Text" }); Label label = new Label { Text = "Enter a search term and press enter or click the magnifying glass to perform a search.", HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.CenterAndExpand }; ListView searchResults = new ListView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill }; searchResults.SetBinding(ListView.ItemsSourceProperty, "SearchResults"); Content = new StackLayout { Children = { searchBar, label, searchResults } }; }
public OpportunitiesPage() { ViewModel.OkButtonTapped += HandleWelcomeViewDisappearing; var collectionView = new CollectionView { ItemTemplate = new OpportunitiesDataTemplate(), SelectionMode = SelectionMode.Single, }; collectionView.SelectionChanged += HandleSelectionChanged; collectionView.SetBinding(CollectionView.ItemsSourceProperty, nameof(OpportunitiesViewModel.VisibleOpportunitiesCollection)); _refreshView = new RefreshView { Content = collectionView }; _refreshView.SetBinding(RefreshView.CommandProperty, nameof(OpportunitiesViewModel.RefreshDataCommand)); _refreshView.SetBinding(RefreshView.IsRefreshingProperty, nameof(OpportunitiesViewModel.IsCollectionRefreshing)); var addButtonToolBar = new ToolbarItem { IconImageSource = "Add", AutomationId = AutomationIdConstants.AddOpportunityButton }; addButtonToolBar.Clicked += HandleAddButtonClicked; ToolbarItems.Add(addButtonToolBar); var searchBar = new SearchBar { AutomationId = AutomationIdConstants.OpportunitySearchBar }; searchBar.SetBinding(SearchBar.TextProperty, nameof(OpportunitiesViewModel.SearchBarText)); _mainLayout = new RelativeLayout(); _mainLayout.Children.Add(searchBar, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent(parent => parent.Width)); _mainLayout.Children.Add(_refreshView, Constraint.Constant(0), Constraint.RelativeToParent(getSearchBarHeight), Constraint.RelativeToParent(parent => parent.Width), Constraint.RelativeToParent(parent => parent.Height - getSearchBarHeight(parent))); Title = PageTitleConstants.OpportunitiesPage; NavigationPage.SetBackButtonTitle(this, ""); Content = _mainLayout; double getSearchBarHeight(RelativeLayout p) => searchBar.Measure(p.Width, p.Height).Request.Height; }
public AllSessionsPage() { searchGrid.Children.Add(Search, 0, 0); searchGrid.Children.Add(Reset, 1, 0); Day.SetBinding(BindablePicker.ItemsSourceProperty, nameof(AllSessionsPageModel.Days)); Track.SetBinding(BindablePicker.ItemsSourceProperty, nameof(AllSessionsPageModel.Tracks)); Track.SetBinding(BindablePicker.SelectedItemProperty, nameof(AllSessionsPageModel.SelectedTrack)); Day.SetBinding(BindablePicker.SelectedItemProperty, nameof(AllSessionsPageModel.SelectedDay)); Reset.SetBinding(Button.CommandProperty, nameof(AllSessionsPageModel.ResetCommand)); Search.SetBinding(SearchBar.SearchCommandProperty, nameof(AllSessionsPageModel.SearchCommand)); Search.SetBinding(SearchBar.TextProperty, nameof(AllSessionsPageModel.SearchText)); SessionList.ItemTemplate = new DataTemplate(typeof(ScheduleItemCell)); SessionList.GroupHeaderTemplate = new DataTemplate(typeof(GroupingTemplate)); SessionList.SetBinding(ListView.ItemsSourceProperty, nameof(AllSessionsPageModel.Sessions)); SessionList.SetBinding(ListView.SelectedItemProperty, nameof(AllSessionsPageModel.SelectedEntry)); SessionList.ItemTapped += SessionList_ItemTapped; var pickerHolder = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { Day, Track, } }; var mainLayout = new StackLayout { BackgroundColor = Color.FromHex("EFEFEF"), Children = { searchGrid, pickerHolder, SessionList } }; Content = mainLayout; }
public OpportunitiesPage() { #region Create the ListView _listView = new ListView { ItemTemplate = new DataTemplate(typeof(OpportunitiesViewCell)), RowHeight = 75 }; _listView.IsPullToRefreshEnabled = true; _listView.SetBinding(ListView.ItemsSourceProperty, nameof(ViewModel.ViewableOpportunitiesData)); _listView.SetBinding(ListView.RefreshCommandProperty, nameof(ViewModel.RefreshAllDataCommand)); #endregion #region Initialize the Toolbar Add Button _addButtonToolBar = new ToolbarItem { Icon = "Add", AutomationId = AutomationIdConstants.AddOpportunityButton }; ToolbarItems.Add(_addButtonToolBar); #endregion #region Create Searchbar _searchBar = new SearchBar { AutomationId = AutomationIdConstants.OpportunitySearchBar }; _searchBar.SetBinding(SearchBar.TextProperty, nameof(ViewModel.SearchBarText)); #endregion _mainLayout = new RelativeLayout(); Func <RelativeLayout, double> getSearchBarHeight = (p) => _searchBar.Measure(p.Width, p.Height).Request.Height; _mainLayout.Children.Add(_searchBar, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent(parent => parent.Width) ); _mainLayout.Children.Add(_listView, Constraint.Constant(0), Constraint.RelativeToParent(parent => getSearchBarHeight(parent)), Constraint.RelativeToParent(parent => parent.Width), Constraint.RelativeToParent(parent => parent.Height - getSearchBarHeight(parent)) ); Title = PageTitleConstants.OpportunitiesPageTitle; NavigationPage.SetBackButtonTitle(this, ""); Content = _mainLayout; DisplayWelcomeView(); }
public ItemsDisplay() { InitializeComponent(); db = Database.getInstanece(); searchBar = "Search"; Binding b = new Binding(); b.Source = this; b.Path = new PropertyPath("searchBar"); b.Mode = BindingMode.TwoWay; SearchBar.SetBinding(TextBox.TextProperty, b); }
public HeaderView() { SearchBar searchBar = new SearchBar { HorizontalOptions = LayoutOptions.FillAndExpand, WidthRequest = 10 }; searchBar.SetBinding(SearchBar.TextProperty, "SearchBarText"); var segment = new SegmentedControl.SegmentedControl { Children = { new SegmentedControlOption { Text = "To Me" }, new SegmentedControlOption { Text = "From Me" }, }, SelectedValue = "To Me", VerticalOptions = LayoutOptions.Center }; segment.ValueChanged += (object sender, EventArgs e) => { var model = (MainPageViewModel)BindingContext; var s = (SegmentedControl.SegmentedControl)sender; if (s.SelectedValue == "To Me") { model.ScoreBoardMaster = model.ToMeScoreboard; } else { model.ScoreBoardMaster = model.FromMeScoreboard; } model.FilterSort(); }; Children.Add(new StackLayout { Orientation = StackOrientation.Vertical, Children = { searchBar, new ContentView { Content = segment,Padding = new Thickness(5, 0) } } }); Children.Add(new ScoreboardHeader()); }
SearchBar createSearchBar() { var searchBar = new SearchBar { Margin = _searchBarMargin, BackgroundColor = Color.FromHex(Theme.Current.BaseBlockColor), CancelButtonColor = Color.FromHex(Theme.Current.BaseAppColor), TextColor = Color.FromHex(Theme.Current.StatisticsBaseTitleColor), Placeholder = CrossLocalization.Translate("stats_students_search_text"), FontFamily = FontsController.GetCurrentFont(), FontSize = FontSizeController.GetSize(NamedSize.Medium, typeof(SearchBar)) }; searchBar.SetBinding(SearchBar.TextProperty, "SearchText"); return(searchBar); }
public void CommandCanExecuteUpdatesEnabled() { var searchBar = new SearchBar(); bool result = false; var bindingContext = new { Command = new Command(() => { }, () => result) }; searchBar.SetBinding(SearchBar.SearchCommandProperty, "Command"); searchBar.BindingContext = bindingContext; Assert.False(searchBar.IsEnabled); result = true; bindingContext.Command.ChangeCanExecute(); Assert.True(searchBar.IsEnabled); }
private void InitializeComponent() { if (ResourceLoader.ResourceProvider != null && ResourceLoader.ResourceProvider(typeof(CarPage).GetTypeInfo().Assembly.GetName(), "Views/CarPage.xaml") != null) { this.__InitComponentRuntime(); return; } if (XamlLoader.XamlFileProvider != null && XamlLoader.XamlFileProvider(base.GetType()) != null) { this.__InitComponentRuntime(); return; } BindingExtension bindingExtension = new BindingExtension(); RowDefinition rowDefinition = new RowDefinition(); RowDefinition rowDefinition2 = new RowDefinition(); ColumnDefinition columnDefinition = new ColumnDefinition(); ColumnDefinition columnDefinition2 = new ColumnDefinition(); BindingExtension bindingExtension2 = new BindingExtension(); TranslateExtension translateExtension = new TranslateExtension(); BindingExtension bindingExtension3 = new BindingExtension(); BindingExtension bindingExtension4 = new BindingExtension(); EventToCommandBehavior eventToCommandBehavior = new EventToCommandBehavior(); SearchBar searchBar = new SearchBar(); BindingExtension bindingExtension5 = new BindingExtension(); BindingExtension bindingExtension6 = new BindingExtension(); TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer(); SvgCachedImage svgCachedImage = new SvgCachedImage(); Grid grid = new Grid(); BindingExtension bindingExtension7 = new BindingExtension(); BindingExtension bindingExtension8 = new BindingExtension(); EventToCommandBehavior eventToCommandBehavior2 = new EventToCommandBehavior(); DataTemplate dataTemplate = new DataTemplate(); ListView listView = new ListView(); Grid grid2 = new Grid(); BindingExtension bindingExtension9 = new BindingExtension(); BindingExtension bindingExtension10 = new BindingExtension(); ActivityIndicator activityIndicator = new ActivityIndicator(); Grid grid3 = new Grid(); NameScope nameScope = new NameScope(); NameScope.SetNameScope(this, nameScope); NameScope.SetNameScope(grid3, nameScope); NameScope.SetNameScope(grid2, nameScope); NameScope.SetNameScope(rowDefinition, nameScope); NameScope.SetNameScope(rowDefinition2, nameScope); NameScope.SetNameScope(grid, nameScope); NameScope.SetNameScope(columnDefinition, nameScope); NameScope.SetNameScope(columnDefinition2, nameScope); NameScope.SetNameScope(searchBar, nameScope); NameScope.SetNameScope(eventToCommandBehavior, nameScope); NameScope.SetNameScope(svgCachedImage, nameScope); NameScope.SetNameScope(tapGestureRecognizer, nameScope); NameScope.SetNameScope(listView, nameScope); ((INameScope)nameScope).RegisterName("listview", listView); if (listView.StyleId == null) { listView.StyleId = "listview"; } NameScope.SetNameScope(eventToCommandBehavior2, nameScope); NameScope.SetNameScope(activityIndicator, nameScope); this.listview = listView; this.SetValue(ViewModelLocator.AutowireViewModelProperty, new bool?(true)); bindingExtension.Path = "Title"; BindingBase binding = ((IMarkupExtension <BindingBase>)bindingExtension).ProvideValue(null); this.SetBinding(Page.TitleProperty, binding); rowDefinition.SetValue(RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("Auto")); grid2.GetValue(Grid.RowDefinitionsProperty).Add(rowDefinition); rowDefinition2.SetValue(RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("*")); grid2.GetValue(Grid.RowDefinitionsProperty).Add(rowDefinition2); grid.SetValue(Grid.RowProperty, 0); grid.SetValue(VisualElement.BackgroundColorProperty, Color.White); grid.SetValue(Xamarin.Forms.Layout.PaddingProperty, new Thickness(10.0)); grid.SetValue(Grid.ColumnSpacingProperty, 10.0); columnDefinition.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("*")); grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition); columnDefinition2.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("24")); grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition2); searchBar.SetValue(Grid.ColumnProperty, 0); bindingExtension2.Path = "CarNo"; BindingBase binding2 = ((IMarkupExtension <BindingBase>)bindingExtension2).ProvideValue(null); searchBar.SetBinding(SearchBar.TextProperty, binding2); translateExtension.Text = "search"; IMarkupExtension markupExtension = translateExtension; XamlServiceProvider xamlServiceProvider = new XamlServiceProvider(); Type typeFromHandle = typeof(IProvideValueTarget); object[] array = new object[0 + 5]; array[0] = searchBar; array[1] = grid; array[2] = grid2; array[3] = grid3; array[4] = this; xamlServiceProvider.Add(typeFromHandle, new SimpleValueTargetProvider(array, SearchBar.PlaceholderProperty)); xamlServiceProvider.Add(typeof(INameScopeProvider), new NameScopeProvider { NameScope = nameScope }); Type typeFromHandle2 = typeof(IXamlTypeResolver); XmlNamespaceResolver xmlNamespaceResolver = new XmlNamespaceResolver(); xmlNamespaceResolver.Add("", "http://xamarin.com/schemas/2014/forms"); xmlNamespaceResolver.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml"); xmlNamespaceResolver.Add("prism", "clr-namespace:Prism.Mvvm;assembly=Prism.Forms"); xmlNamespaceResolver.Add("local", "clr-namespace:RFID"); xmlNamespaceResolver.Add("b", "clr-namespace:Prism.Behaviors;assembly=Prism.Forms"); xmlNamespaceResolver.Add("svg", "clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"); xamlServiceProvider.Add(typeFromHandle2, new XamlTypeResolver(xmlNamespaceResolver, typeof(CarPage).GetTypeInfo().Assembly)); xamlServiceProvider.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(22, 60))); object placeholder = markupExtension.ProvideValue(xamlServiceProvider); searchBar.Placeholder = placeholder; searchBar.SetValue(SearchBar.TextColorProperty, new Color(0.501960813999176, 0.501960813999176, 0.501960813999176, 1.0)); bindingExtension3.Path = "SearchCommand"; BindingBase binding3 = ((IMarkupExtension <BindingBase>)bindingExtension3).ProvideValue(null); searchBar.SetBinding(SearchBar.SearchCommandProperty, binding3); searchBar.SetValue(VisualElement.BackgroundColorProperty, new Color(0.93725490570068359, 0.93725490570068359, 0.93725490570068359, 1.0)); eventToCommandBehavior.SetValue(EventToCommandBehavior.EventNameProperty, "TextChanged"); bindingExtension4.Path = "SearchCommand"; BindingBase binding4 = ((IMarkupExtension <BindingBase>)bindingExtension4).ProvideValue(null); eventToCommandBehavior.SetBinding(EventToCommandBehavior.CommandProperty, binding4); ((ICollection <Behavior>)searchBar.GetValue(VisualElement.BehaviorsProperty)).Add(eventToCommandBehavior); grid.Children.Add(searchBar); svgCachedImage.SetValue(Grid.ColumnProperty, 1); svgCachedImage.SetValue(VisualElement.WidthRequestProperty, 24.0); bindingExtension5.Path = "IsException"; BindingBase binding5 = ((IMarkupExtension <BindingBase>)bindingExtension5).ProvideValue(null); svgCachedImage.SetBinding(VisualElement.IsVisibleProperty, binding5); svgCachedImage.SetValue(VisualElement.HeightRequestProperty, 24.0); svgCachedImage.SetValue(CachedImage.SourceProperty, new FFImageLoading.Forms.ImageSourceConverter().ConvertFromInvariantString("plus.svg")); bindingExtension6.Path = "AddCommand"; BindingBase binding6 = ((IMarkupExtension <BindingBase>)bindingExtension6).ProvideValue(null); tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, binding6); svgCachedImage.GestureRecognizers.Add(tapGestureRecognizer); grid.Children.Add(svgCachedImage); grid2.Children.Add(grid); listView.SetValue(Grid.RowProperty, 1); listView.SetValue(VisualElement.BackgroundColorProperty, new Color(0.98039215803146362, 0.98039215803146362, 0.98039215803146362, 1.0)); bindingExtension7.Path = "CarSource"; BindingBase binding7 = ((IMarkupExtension <BindingBase>)bindingExtension7).ProvideValue(null); listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, binding7); listView.ItemSelected += this.Handle_ItemSelected; eventToCommandBehavior2.SetValue(EventToCommandBehavior.EventNameProperty, "ItemTapped"); bindingExtension8.Path = "SelectCommand"; BindingBase binding8 = ((IMarkupExtension <BindingBase>)bindingExtension8).ProvideValue(null); eventToCommandBehavior2.SetBinding(EventToCommandBehavior.CommandProperty, binding8); eventToCommandBehavior2.SetValue(EventToCommandBehavior.EventArgsParameterPathProperty, "Item"); ((ICollection <Behavior>)listView.GetValue(VisualElement.BehaviorsProperty)).Add(eventToCommandBehavior2); IDataTemplate dataTemplate2 = dataTemplate; CarPage.< InitializeComponent > _anonXamlCDataTemplate_4 <InitializeComponent> _anonXamlCDataTemplate_ = new CarPage.< InitializeComponent > _anonXamlCDataTemplate_4(); object[] array2 = new object[0 + 5]; array2[0] = dataTemplate; array2[1] = listView; array2[2] = grid2; array2[3] = grid3; array2[4] = this;
public CurrenciesPage(Currencies currencies, ObservableCollection <Currency> bindableCurrencies) { Title = "Currencies"; WrappedCurrencies = new List <WrappedCurrency>(); BindableCurrencies = bindableCurrencies; bindableCurrencies.Clear(); foreach (var currency in currencies.currencies) { bool isSelected = false; if (currencies.defaultCurrencies.Contains(currency.Name)) { isSelected = true; bindableCurrencies.Add(currency); } WrappedCurrencies.Add(new WrappedCurrency() { Currency = currency, IsSelected = isSelected }); } var stackLayout = new StackLayout(); ListView mainList = new ListView() { ItemsSource = WrappedCurrencies, ItemTemplate = new DataTemplate(typeof(WrappedCurrencySelectionTemplate)), }; mainList.ItemSelected += (sender, e) => { if (e.SelectedItem == null) { return; } var o = (WrappedCurrency)e.SelectedItem; o.IsSelected = !o.IsSelected; ((ListView)sender).SelectedItem = null; //de-select }; var searchBar = new SearchBar { Placeholder = "Filter by", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, BindingContext = ViewModel }; searchBar.SetBinding <CurrenciesViewModel>(SearchBar.TextProperty, vm => vm.SearchBarText, BindingMode.TwoWay); searchBar.TextChanged += (sender, e) => { if (string.IsNullOrEmpty(searchBar.Text) || string.IsNullOrWhiteSpace(searchBar.Text)) { mainList.ItemsSource = WrappedCurrencies; } else { searchBar.Text = searchBar.Text.ToUpper(); mainList.ItemsSource = WrappedCurrencies. Where(wrappedCurrency => wrappedCurrency.Currency.Name.Contains(searchBar.Text)).ToList(); } }; stackLayout.Children.Add(mainList); stackLayout.Children.Add(searchBar); Content = stackLayout; if (Device.OS == TargetPlatform.Windows) { // fix issue where rows are badly sized (as tall as the screen) on WinPhone8.1 mainList.RowHeight = 40; // also need icons for Windows app bar (other platforms can just use text) ToolbarItems.Add(new ToolbarItem("All", "check.png", SelectAll, ToolbarItemOrder.Primary)); ToolbarItems.Add(new ToolbarItem("None", "cancel.png", SelectNone, ToolbarItemOrder.Primary)); } else { ToolbarItems.Add(new ToolbarItem("All", null, SelectAll, ToolbarItemOrder.Primary)); ToolbarItems.Add(new ToolbarItem("None", null, SelectNone, ToolbarItemOrder.Primary)); } }
private SfPopupLayout CreateSearchPopoutLayout() { var popup = new SfPopupLayout { PopupView = { ShowHeader = false, ShowFooter = false, AnimationMode = AnimationMode.Zoom } }; var stack = new StackLayout(); var searchBar = new SearchBar(); searchBar.SetBinding(SearchBar.TextProperty, "AddressText"); searchBar.TextChanged += OnSearchBarTextChanged; var topStack = new StackLayout { IsVisible = false, Orientation = StackOrientation.Horizontal, Spacing = 0.0, HorizontalOptions = LayoutOptions.EndAndExpand }; var backButton = new SfButton(); backButton.Clicked += (sender, args) => { popup.IsOpen = false; popup.IsVisible = false; }; Application.Current.Resources.TryGetValue("Back", out var resource); // backButton.Text = (string) resource; // backButton.Style = (Style) Resources["NavigationBarButtonStyle"]; topStack.Children.Add(backButton); var searchBorder = new SfBorder(); var borderlessEntry = new BorderlessEntry(); borderlessEntry.SetBinding(Entry.TextProperty, "AddressText"); borderlessEntry.Placeholder = "Search here"; borderlessEntry.HorizontalOptions = LayoutOptions.FillAndExpand; // borderlessEntry.Style = (Style) Resources["SearchEntryStyle"]; // searchBorder.Children.Append(borderlessEntry); topStack.Children.Add(borderlessEntry); var sfListView = new SfListView { ItemsSource = viewModel.Addresses, Margin = new Thickness(8, 4), TapCommand = viewModel.SearchLocationTapped }; // SfListView.SetBinding(SfListView.ItemsSourceProperty, "Addresses"); var listViewDataTemplate = new DataTemplate(() => { var grid = new Grid(); var addressForm = new Label { FontAttributes = FontAttributes.None, BackgroundColor = Color.White, FontSize = 12 }; ; addressForm.SetBinding(Label.TextProperty, new Binding("FreeformAddress")); grid.Children.Add(addressForm); return(grid); }); sfListView.ItemTemplate = listViewDataTemplate; stack.Children.Add(searchBar); stack.Children.Add(sfListView); popup.PopupView.ContentTemplate = new DataTemplate(() => stack); return(popup); }
public static StackLayout SearchSelectAddVehicle(ContentView titleBar, PairNewVehicleViewModel ViewModel) { Vm = ViewModel; RegisterEvents(); if (ViewModel.VehicleModels == null) { ViewModel.MoveToAdd = true; } else if (ViewModel.VehicleModels?.Count == 0) { ViewModel.GetVehiclesFromDb(); if (ViewModel.VehicleModels.Count == 0) { ViewModel.MoveToAdd = true; } } var lblTitle = GetUIElement.GetFirstElement <Label>(titleBar.Content as StackLayout); lblTitle.Text = Langs.Const_Screen_Title_Select_Vehicle; var srchVehicle = new SearchBar { WidthRequest = App.ScreenSize.Width * .9, }; srchVehicle.SetBinding(SearchBar.TextProperty, new Binding("VehicleSearch")); var lblNoneFound = new Label { Text = Langs.Const_Label_No_Search_Result, TextColor = Color.White, FontFamily = Helper.BoldFont, IsVisible = false }; srchVehicle.SearchButtonPressed += (sender, e) => { var _ = ViewModel.SearchBasedOnVehicle(); if (!_) { lblNoneFound.IsVisible = true; } }; var grid = new Grid { WidthRequest = App.ScreenSize.Width }; grid.ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = App.ScreenSize.Width } }; grid.RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = App.ScreenSize.Height * .5 }, new RowDefinition { Height = GridLength.Auto } }; var activitySpinner = new ActivityIndicator { BackgroundColor = Color.Transparent, WidthRequest = 40, IsRunning = true }; activitySpinner.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsBusy")); listView = new ListView(ListViewCachingStrategy.RecycleElement) { IsPullToRefreshEnabled = true, ItemsSource = ViewModel.VehicleModels, ItemTemplate = new DataTemplate(typeof(RegisteredVehicleViewCell)), SeparatorVisibility = SeparatorVisibility.None, HasUnevenRows = true }; listView.ItemSelected += (sender, e) => { var obj = e.SelectedItem as VehicleModel; ViewModel.SelectedVehicle = obj; }; listView.Refreshing += (sender, e) => { listView.IsRefreshing = true; ViewModel.CmdGetRegisteredVehicles.Execute(null); listView.IsRefreshing = false; }; var dummyCell = new StackLayout { Padding = new Thickness(12), BackgroundColor = FormsConstants.AppyDarkShade, VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Horizontal, Children = { new Image { Source = "add_new".CorrectedImageSource(), HeightRequest = 48 }, new Label { Text = Langs.Const_Label_Add_Vehicle, FontFamily = Helper.RegFont, TextColor = Color.White, HeightRequest = 48, VerticalTextAlignment = TextAlignment.Center } } }; var dummyListCellRecogniser = new TapGestureRecognizer { NumberOfTapsRequired = 1, Command = new Command(() => ViewModel.MoveToAdd = !ViewModel.MoveToAdd) }; dummyCell.GestureRecognizers.Add(dummyListCellRecogniser); var dummyListCell = new StackLayout { HeightRequest = 60, InputTransparent = true, Padding = new Thickness(8), Children = { dummyCell } }; var listStack = new StackLayout { WidthRequest = App.ScreenSize.Width * .9, Padding = new Thickness(4), Children = { lblNoneFound, activitySpinner, listView, dummyListCell } }; grid.Children.Add(new StackLayout { WidthRequest = App.ScreenSize.Width, HorizontalOptions = LayoutOptions.Center, Children = { new StackLayout { WidthRequest = App.ScreenSize.Width * .9, HorizontalOptions = LayoutOptions.Center, Children = { new Label { FormattedText = FormattedProgress.GenerateProgress(true, false, false), HorizontalTextAlignment = TextAlignment.Center }, srchVehicle } }, new BoxView { WidthRequest = App.ScreenSize.Width, HeightRequest = 1, BackgroundColor = Color.White }, } }, 0, 0); var arrowButton = ArrowBtn.ArrowButton(Langs.Const_Button_Manage_Vehicle_Step_1, App.ScreenSize.Width * .9, new Action(() => { if (ViewModel.RegisteredVehicles?.Vehicles.Count != 0) { ViewModel.MoveToPair = true; } })); grid.Children.Add(new StackLayout { WidthRequest = App.ScreenSize.Width, HorizontalOptions = LayoutOptions.Center, Children = { new StackLayout { WidthRequest = App.ScreenSize.Width * .9, HorizontalOptions = LayoutOptions.Center, Children = { listStack } }, new BoxView { WidthRequest = App.ScreenSize.Width, HeightRequest = 1, BackgroundColor = Color.White }, arrowButton } }, 0, 1); var inStack = new StackLayout { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, HeightRequest = 100, Children = { new Label { Text = " " } } }; var imgHelp = new Image { Source = "help".CorrectedImageSource(), HeightRequest = 32 }; var imgHelpGesture = new TapGestureRecognizer { NumberOfTapsRequired = 1, Command = new Command(() => { var src = imgHelp.Source as FileImageSource; if (src.File == "help".CorrectedImageSource()) { var _ = new SpeechBubble(Langs.Const_Msg_Pair_Vehicle_Help_Description_1, App.ScreenSize.Width * .8, FormsConstants.AppySilverGray); if (inStack.Children.Count > 0) { inStack.Children.RemoveAt(0); } inStack.Children.Add(_); imgHelp.Source = "help_close".CorrectedImageSource(); } else { imgHelp.Source = "help".CorrectedImageSource(); inStack.Children.RemoveAt(0); } }) }; imgHelp.GestureRecognizers.Add(imgHelpGesture); var helpContainer = new StackLayout { Orientation = StackOrientation.Vertical, WidthRequest = App.ScreenSize.Width, HorizontalOptions = LayoutOptions.Start, Children = { inStack, new StackLayout { HorizontalOptions = LayoutOptions.End, HeightRequest = 64, VerticalOptions = LayoutOptions.Start, Children = { imgHelp } } } }; grid.Children.Add(helpContainer, 0, 2); return(new StackLayout { WidthRequest = App.ScreenSize.Width, TranslationX = -6, HorizontalOptions = LayoutOptions.Center, HeightRequest = App.ScreenSize.Height - 100, Children = { grid } }); }
public void CommandCanExecuteUpdatesEnabled () { var searchBar = new SearchBar (); bool result = false; var bindingContext = new { Command = new Command (() => { }, () => result) }; searchBar.SetBinding (SearchBar.SearchCommandProperty, "Command"); searchBar.BindingContext = bindingContext; Assert.False (searchBar.IsEnabled); result = true; bindingContext.Command.ChangeCanExecute (); Assert.True (searchBar.IsEnabled); }