public ListViewEx() { var classNames = new[] { "Building Cross Platform Apps with Xamarin Part1", "Building Cross Platform Apps with Xamarin Part2", "Building Cross Platform Apps with Xamarin Part3" }; //TODO: Translate into XAML Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0); var listView = new ListView(); //listView.ItemsSource = classNames; listView.ItemsSource = PluralsightCourse.GetCourseList(); var cell = new DataTemplate(typeof(TextCell)); //cell.SetBinding(TextCell.TextProperty, new Binding(".")); cell.SetBinding(TextCell.TextProperty, new Binding("Title")); cell.SetBinding(TextCell.DetailProperty, new Binding("Author")); cell.SetValue(TextCell.TextColorProperty, Color.Red); cell.SetValue(TextCell.DetailColorProperty,Color.Yellow); listView.ItemTemplate = cell; Content = listView; }
private async Task Init() { _itemSelectedEventHandler = (sender, args) => { if (args.SelectedItem == null) return; var selectedItem = args.SelectedItem as ResourceListItemViewModel; Navigation.PushAsync(new ResourceViewPage(selectedItem)); }; BackgroundColor = Constants.HtBoxDarkBrown; Padding = new Thickness(0, Device.OnPlatform(20,0,0), 0, 0); Title = "Resources for: Big Disaster"; //TODO - Add Disaster Name // TODO: Get data from the API //ICrisisCheckInApiClient apiClient = new CrisisCheckInApiClient(); //var dtos = await apiClient.GetCommitmentsList(2); //TODO: wire up to Auth0 so we don't have to pass person ID //Data = dtos.Select(c => new DisasterListItemViewModel(c)); ResourceList = new List<ResourceListItemViewModel> { new ResourceListItemViewModel { Description = "Dump Truck", Type = "Heavy Machines", PersonFullName = "Bob Smith", Location_State = "Maine", Qty = 2 }, new ResourceListItemViewModel { Description = "Poland Spring Water", Type = "Water", PersonFullName = "Mike Smith", Location_State = "Maine", Qty = 500 } }; _resourceListView = new ListView { ItemsSource = ResourceList, BackgroundColor = Constants.HtBoxDarkBrown }; _resourceListView.ItemSelected += _itemSelectedEventHandler; var cell = new DataTemplate(typeof(TextCell)); cell.SetBinding(TextCell.TextProperty, new Binding("Type")); cell.SetBinding(TextCell.DetailProperty, new Binding("Description")); cell.SetValue(TextCell.TextColorProperty, Color.White); cell.SetValue(TextCell.DetailColorProperty, Constants.HtBoxLightBrown); _resourceListView.ItemTemplate = cell; Content = _resourceListView; }
private DataTemplate CreateRequestCell() { var cell = new DataTemplate(typeof (TextCell)); cell.SetBinding(TextCell.TextProperty, new Binding("Description")); cell.SetBinding(TextCell.DetailProperty, new Binding("Location")); cell.SetValue(TextCell.TextColorProperty, Color.White); cell.SetValue(TextCell.DetailColorProperty, Constants.HtBoxLightBrown); return cell; }
public MenuPage() { InitializeComponent(); OptionItems.Add(new OptionItem() { Title = "Projeções" }); OptionItems.Add(new OptionItem() { Title = "Sobre" }); OptionItems.Add(new OptionItem() { Title = "Logout" }); var cell = new DataTemplate(typeof(DarkTextCell)); cell.SetBinding(TextCell.TextProperty, "Title"); cell.SetBinding(ImageCell.ImageSourceProperty, "IconSource"); cell.SetValue(TextCell.TextColorProperty, "#F8F8F8"); cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent); listMenu.ItemTemplate = cell; listMenu.ItemsSource = OptionItems; }
public MenuListTemplate() { List<MenuItem> data = new MenuListData(); this.ItemsSource = data; this.VerticalOptions = LayoutOptions.FillAndExpand; this.BackgroundColor = Theme.NavBackgroundColor; this.SeparatorColor = Color.Black; this.Margin = new Thickness(5); var menuDataTemplate = new DataTemplate(() => { var pageImage = new Image { VerticalOptions = LayoutOptions.Center, HeightRequest = 30, Margin = new Thickness(0, 0, 10, 0) }; var pageLabel = new Label { VerticalOptions = LayoutOptions.Center, TextColor = Theme.TextColor, FontSize = 20, }; pageImage.SetBinding(Image.SourceProperty, "IconSource"); pageLabel.SetBinding(Label.TextProperty, "Name"); var layout = new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Center, Children = { pageImage, pageLabel } }; var menuFrame = new Frame { OutlineColor = Theme.NavBackgroundColor, BackgroundColor = Theme.NavBackgroundColor, VerticalOptions = LayoutOptions.Center, Padding = new Thickness(10), Content = layout }; return new ViewCell { View = menuFrame }; }); var cell = new DataTemplate(typeof(ViewCell)); cell.SetBinding(TextCell.TextProperty, "Name"); cell.SetValue(TextCell.TextColorProperty, Color.FromHex("2f4f4f")); this.ItemTemplate = menuDataTemplate; this.SelectedItem = data[0]; }
public MenuPage() { OptionItems.Add(new LeadsOptionItem()); OptionItems.Add(new ContactsOptionItem()); OptionItems.Add(new AccountsOptionItem()); OptionItems.Add(new OpportunitiesOptionItem()); BackgroundColor = Color.FromHex("333333"); var layout = new StackLayout { Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand }; var label = new ContentView { Padding = new Thickness(10, 36, 0, 5), Content = new Xamarin.Forms.Label { TextColor = Color.FromHex("AAAAAA"), Text = "MENU", } }; Device.OnPlatform( iOS: () => ((Xamarin.Forms.Label)label.Content).Font = Font.SystemFontOfSize(NamedSize.Micro), Android: () => ((Xamarin.Forms.Label)label.Content).Font = Font.SystemFontOfSize(NamedSize.Medium) ); layout.Children.Add(label); Menu = new ListView { ItemsSource = OptionItems, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent }; var cell = new DataTemplate(typeof(DarkTextCell)); cell.SetBinding(TextCell.TextProperty, "Title"); cell.SetBinding(TextCell.DetailProperty, "Count"); cell.SetBinding(ImageCell.ImageSourceProperty, "IconSource"); cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent); Menu.ItemTemplate = cell; layout.Children.Add(Menu); Content = layout; }
public MenuView() { this.Icon = "slideout.png"; this.Title = "menu"; BindingContext = viewModel = new HomeViewModel(); this.BackgroundImage = "menubk.png"; var label = new ContentView { Padding = new Thickness(10, 36, 0, 5), Content = new Xamarin.Forms.Label { TextColor = Color.White, Text = "MENU", } }; Menu = new ListView { ItemsSource = viewModel.MenuItems, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, }; var cell = new DataTemplate(typeof(MenuCell)); cell.SetBinding(TextCell.TextProperty, BaseViewModel.TitlePropertyName); cell.SetBinding(ImageCell.ImageSourceProperty, BaseViewModel.IconPropertyName); cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent); Menu.ItemTemplate = cell; Content = new StackLayout { Spacing = 10, VerticalOptions = LayoutOptions.FillAndExpand, Children = { label, Menu} }; }
public MenuPage () { MenuItems.AddRange (ViewModels.MenuItem.All()); BackgroundColor = ColorHelper.MenuBackgroundColor; var layout = new StackLayout { Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand }; var headerText = new ContentView { Padding = new Thickness(10, 36, 0, 5), Content = new Xamarin.Forms.Label { TextColor = Color.White, Text = "DNA.XForms Sample", Font = Font.SystemFontOfSize (NamedSize.Medium), } }; layout.Children.Add(headerText); Menu = new ListView { ItemsSource = MenuItems, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, RowHeight = 48, }; var cell = new DataTemplate(typeof(ImageCell)); cell.SetBinding(TextCell.TextProperty, "Title"); cell.SetBinding(ImageCell.ImageSourceProperty, "Icon"); cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent); Menu.ItemTemplate = cell; layout.Children.Add(Menu); this.Content = layout; }
public ForecastPage(RootPage rootPage, Forecast forecast) { this._rootPage = rootPage; _forecast = forecast; BindingContext = new ForecastViewModel (Navigation, _forecast); NavigationPage.SetHasNavigationBar (this, false); var masterGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition{ Height = new GridLength (0.3, GridUnitType.Star) }, new RowDefinition{ Height = new GridLength (0.3, GridUnitType.Star) }, new RowDefinition{ Height = new GridLength (0.4, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection{ new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) } } }; var forecastListview = new ListView (); var forecastListviewItemTemplate = new DataTemplate (typeof(ImageCell)); forecastListviewItemTemplate.SetBinding (ImageCell.TextProperty, "ItemTemplateTextProperty"); forecastListviewItemTemplate.SetValue(ImageCell.TextColorProperty, Color.FromHex("#3498DB")); forecastListviewItemTemplate.SetBinding (ImageCell.DetailProperty, "ItemTemplateDetailProperty"); forecastListviewItemTemplate.SetValue(ImageCell.DetailColorProperty, Color.White); forecastListviewItemTemplate.SetBinding (ImageCell.ImageSourceProperty, "Icon"); forecastListview.ItemTemplate = forecastListviewItemTemplate; forecastListview.SetBinding<ForecastViewModel> (ListView.ItemsSourceProperty, vm => vm.GroupList); var refreshImage = new ImageButton () { Image = "Refresh", ImageHeightRequest = 70, ImageWidthRequest = 70, BorderColor = Color.Transparent, VerticalOptions = LayoutOptions.Start, BackgroundColor = Color.Transparent }; refreshImage.Clicked += (object sender, EventArgs e) => { /*_rootPage.ShowLoadingDialogAsync ();*/ }; var topGrid = new Grid {RowDefinitions = new RowDefinitionCollection { new RowDefinition{ Height = new GridLength (1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition{ Width = new GridLength (0.8, GridUnitType.Star) }, new ColumnDefinition{ Width = new GridLength (0.2, GridUnitType.Star) }, } }; topGrid.Children.Add (CreateForecastStatusStackLayout (), 0, 0); topGrid.Children.Add (refreshImage, 1, 0); masterGrid.Children.Add (topGrid, 0, 0); masterGrid.Children.Add (CreateMiddleStackLayout (), 0, 1); masterGrid.Children.Add (forecastListview, 0, 2); Content = masterGrid; }
public FolderSelectionPage(string path, Action updateAction, Color textColor, Color backgroundColor) : base() { this.path = path; this.updateAction = updateAction; Title = path; NavigationPage.SetTitleIcon(this, "HomeIcon.png"); NavigationPage.SetBackButtonTitle(this, string.Empty); this.ToolbarItems.Add(new ToolbarItem(Catalog.GetString("New folder"), null, () => { App.Click(); var cfg = new PromptConfig(); cfg.Message = Catalog.GetString("New folder name"); cfg.Title = Catalog.GetString("New folder"); cfg.OnResult = (result) => { Device.BeginInvokeOnMainThread(() => { App.Click(); if (result.Ok) { Directory.CreateDirectory(Path.Combine(path, result.Text)); this.path = Path.Combine(path, result.Text); UpdateDirectories(); } }); }; UserDialogs.Instance.Prompt(cfg); }, ToolbarItemOrder.Secondary)); var cell = new DataTemplate(typeof(TextCell)); cell.SetValue(TextCell.TextColorProperty, textColor); cell.SetBinding(TextCell.TextProperty, "Name"); list = new ListView() { BackgroundColor = backgroundColor, RowHeight = 50, HasUnevenRows = false, ItemTemplate = cell, ItemsSource = new PathItem[] {}, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; list.ItemTapped += (object sender, ItemTappedEventArgs e) => { var pathItem = ((PathItem)e.Item); this.path = pathItem.Path; Settings.Current.AddOrUpdateValue<string>(Settings.CartridgePathKey, this.path); if(updateAction != null) { updateAction(); } UpdateDirectories(); }; // ((StackLayout)ContentLayout).Children.Add(list); Content = list; UpdateDirectories(); }
private async Task Init() { _itemSelectedEventHandler = (sender, args) => { if (args.SelectedItem == null) return; var listView = sender as ListView; var selectedItem = args.SelectedItem as DisasterViewModel; if (selectedItem != null) { Navigation.PushAsync(new CommitmentPage(selectedItem.CommitmentData)); } if (listView != null) { listView.SelectedItem = null; } }; BackgroundColor = Constants.HtBoxDarkBrown; // TODO: Implement a progress indicator ICrisisCheckInApiClient apiClient = new CrisisCheckInApiClient(); var dtos = await apiClient.GetCommitmentsList(2); //TODO: wire up to Auth0 so we don't have to pass person ID // Data = dtos.Select(c => new DisasterViewModel(c)); _disasterListView = new ListView { ItemsSource = Data, BackgroundColor = Constants.HtBoxDarkBrown }; _disasterListView.ItemSelected += _itemSelectedEventHandler; var cell = new DataTemplate(typeof(TextCell)); cell.SetBinding(TextCell.TextProperty, new Binding("DisasterName")); cell.SetBinding(TextCell.DetailProperty, new Binding("DisasterStatusAndDate")); cell.SetValue(TextCell.TextColorProperty, Color.White); cell.SetValue(TextCell.DetailColorProperty, Constants.HtBoxLightBrown); _disasterListView.ItemTemplate = cell; Content = _disasterListView; }
private Grid CreateScheduleGrid () { var scheduleGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength (1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }, }, BackgroundColor = Color.White }; var listview = new ListView {SeparatorVisibility = SeparatorVisibility.None}; //Don't allow selection listview.ItemSelected += (sender, e) => { listview.SelectedItem = null; }; var itemTemplate = new DataTemplate (typeof(ExtendedTextCell)); var cellPadding = new Thickness(40, 0, 0, 0); Device.OnPlatform(WinPhone:() => { cellPadding = new Thickness(25,0,0,0); }); itemTemplate.SetValue (ExtendedTextCell.ThicknessProperty, cellPadding); itemTemplate.SetValue (ExtendedTextCell.LeftColumnWidthProperty, new GridLength (1.0, GridUnitType.Star)); itemTemplate.SetBinding (ExtendedTextCell.LeftTextProperty, "Day"); itemTemplate.SetValue (ExtendedTextCell.LeftTextColorProperty, Color.Black); itemTemplate.SetBinding (ExtendedTextCell.LeftDetailProperty, "HoursOfOperation"); itemTemplate.SetValue (ExtendedTextCell.LeftDetailColorProperty, Color.Gray); listview.ItemTemplate = itemTemplate; listview.BindingContext = _extendedMap; listview.SetBinding<ExtendedMap> (ListView.ItemsSourceProperty, vm => vm.SelectedPin.ScheduleEntries); scheduleGrid.Children.Add (listview, 0, 0); return scheduleGrid; }
private View CreateOtherView () { var contentView = new ContentView { BackgroundColor = Color.White }; var listview = new ListView {SeparatorVisibility = SeparatorVisibility.None}; //Don't allow selection listview.ItemSelected += (sender, e) => { listview.SelectedItem = null; }; var itemTemplate = new DataTemplate (typeof(ExtendedTextCell)); itemTemplate.SetValue (ExtendedTextCell.LeftColumnWidthProperty, new GridLength (0.85, GridUnitType.Star)); itemTemplate.SetValue (ExtendedTextCell.RightColumnWidthProperty, new GridLength (0.15, GridUnitType.Star)); itemTemplate.SetBinding (ExtendedTextCell.LeftTextProperty, "Key"); itemTemplate.SetValue (ExtendedTextCell.LeftTextColorProperty, Color.Black); itemTemplate.SetBinding (ExtendedTextCell.LeftDetailProperty, "Value"); itemTemplate.SetValue (ExtendedTextCell.LeftDetailColorProperty, Color.Gray); listview.ItemTemplate = itemTemplate; listview.BindingContext = _extendedMap; listview.SetBinding<ExtendedMap> (ListView.ItemsSourceProperty, vm => vm.SelectedPin.Others); contentView.Content = listview; return contentView; }
public SearchListTemplate(IReadOnlyList<LaunchData> launchList, OrderBy order) { IEnumerable<SimpleLaunchData> simpleLaunchList = null; switch (order) { case OrderBy.Net: simpleLaunchList = launchList.Select(launchPair => new SimpleLaunchData { LaunchId = launchPair.Launch.Id, Name = launchPair.Launch.Name, Net = launchPair.Launch.Status == 2 ? DateTime.Now.AddMonths(1).AddDays(-1) : TimeConverter.DetermineTimeSettings(launchPair.Launch.Net, App.Settings.UseLocalTime), LaunchNet = launchPair.Launch.Status == 2 || launchPair.Launch.Status == 0 && launchPair.Launch.Net.TimeOfDay.Ticks == 0 ? "TBD" : TimeConverter.SetStringTimeFormat(launchPair.Launch.Net, App.Settings.UseLocalTime) }).OrderBy(x => x.Net).ToList(); break; case OrderBy.Status: var statusGoList = launchList.Where(x => LaunchStatusEnum.GetLaunchStatusById(x.Launch.Status) == LaunchStatus.Go).Select(launchPair => new SimpleLaunchData { LaunchId = launchPair.Launch.Id, Name = launchPair.Launch.Name, Net = launchPair.Launch.Status == 2 ? DateTime.Now.AddMonths(1).AddDays(-1) : TimeConverter.DetermineTimeSettings(launchPair.Launch.Net, App.Settings.UseLocalTime), LaunchNet = launchPair.Launch.Status == 2 || launchPair.Launch.Status == 0 && launchPair.Launch.Net.TimeOfDay.Ticks == 0 ? "TBD" : TimeConverter.SetStringTimeFormat(launchPair.Launch.Net, App.Settings.UseLocalTime) }).OrderBy(x => x.Net).ToList(); var statusHoldList = launchList.Where(x => LaunchStatusEnum.GetLaunchStatusById(x.Launch.Status) != LaunchStatus.Go).Select(launchPair => new SimpleLaunchData { LaunchId = launchPair.Launch.Id, Name = launchPair.Launch.Name, Net = launchPair.Launch.Status == 2 ? DateTime.Now.AddMonths(1).AddDays(-1) : TimeConverter.DetermineTimeSettings(launchPair.Launch.Net, App.Settings.UseLocalTime), LaunchNet = launchPair.Launch.Status == 2 || launchPair.Launch.Status == 0 && launchPair.Launch.Net.TimeOfDay.Ticks == 0 ? "TBD" : TimeConverter.SetStringTimeFormat(launchPair.Launch.Net, App.Settings.UseLocalTime) }).OrderBy(x => x.Net).ToList(); simpleLaunchList = statusGoList.Concat(statusHoldList); break; default: throw new ArgumentOutOfRangeException(nameof(order), order, null); } ItemsSource = simpleLaunchList; VerticalOptions = LayoutOptions.FillAndExpand; BackgroundColor = Theme.BackgroundColor; SeparatorColor = Theme.FrameColor; HasUnevenRows = true; var menuDataTemplate = new DataTemplate(() => { var nameLabel = new Label { VerticalOptions = LayoutOptions.Center, TextColor = Theme.TextColor, FontSize = Device.OnPlatform(16, 20, 16), FontAttributes = FontAttributes.Bold }; var netLabel = new Label { VerticalOptions = LayoutOptions.Center, TextColor = Theme.TextColor, FontSize = 14, }; nameLabel.SetBinding(Label.TextProperty, "Name"); netLabel.SetBinding(Label.TextProperty, "LaunchNet"); var layout = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.Center, Children = { nameLabel, netLabel } }; var searchFrame = new MarginFrame(5, Theme.BackgroundColor) { Content = new Frame { OutlineColor = Theme.FrameColor, BackgroundColor = Theme.BackgroundColor, VerticalOptions = LayoutOptions.Center, Padding = new Thickness(5), Content = layout, Margin = new Thickness(0, 0, 12, 0), } }; return new ViewCell { View = searchFrame }; }); var cell = new DataTemplate(typeof(ViewCell)); cell.SetBinding(TextCell.TextProperty, "Name"); cell.SetValue(TextCell.TextColorProperty, Color.FromHex("2f4f4f")); ItemTemplate = menuDataTemplate; SelectedItem = launchList.Count != 0 ? launchList[0] : null; Margin = new Thickness(0, 0, 0, 30); }
public ShareListPage (Task task) { _task = task; _shares = new ObservableCollection<AADObject> (); #region UI Init this.Title = "tdlr;"; NavigationPage.SetHasNavigationBar (this, false); _add = new Label { Text = "+", TextColor = Color.White, FontSize = 30, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, IsVisible = true, Opacity = 1 }; _done = new Image { Aspect = Aspect.AspectFit, Source = ImageSource.FromFile ("ic_done_white.png"), HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, IsVisible = true, Opacity = 1, }; _unselect = new Image { Aspect = Aspect.AspectFit, Source = ImageSource.FromFile ("ic_done_white.png"), HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, IsVisible = false, Opacity = 0, }; Label vr = new Label { Text = "|", TextColor = Color.White, FontSize = 24, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, }; _delete = new Image { Aspect = Aspect.AspectFit, Source = ImageSource.FromFile("ic_delete.png"), HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, IsVisible = false, Opacity = 0 }; Label header = new Label { Text = "Currently Shared With:", TextColor = Color.Black, FontSize = 18, FontFamily = "Montserrat-UltraLight", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, }; _shareList = new ListView { ItemsSource = _shares, }; var cell = new DataTemplate(typeof(TextCell)); cell.SetValue (TextCell.TextColorProperty, Color.Black); _shareList.ItemTemplate = cell; _shareList.ItemTemplate.SetBinding(TextCell.TextProperty, "displayName"); Image menu = new Image { Aspect = Aspect.AspectFit, Source = ImageSource.FromFile ("ic_menu_white.png"), HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, }; _navbar = new StackLayout { Orientation = StackOrientation.Horizontal, HeightRequest = 50, Padding = new Thickness(10, 0, 20, 0), Spacing = 5, BackgroundColor = Color.Black, Children = { menu, new Label { Text = " tdlr;", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center, FontFamily = "Pacifico", FontSize = 24, TextColor = Color.FromRgb(240,128,128) }, _delete, _add, vr, _done, _unselect } }; #endregion #region Event Listeners _done.GestureRecognizers.Add (new TapGestureRecognizer (OnDoneClicked)); _add.GestureRecognizers.Add (new TapGestureRecognizer (OnAddClicked)); _unselect.GestureRecognizers.Add (new TapGestureRecognizer (OnUnselectClicked)); _delete.GestureRecognizers.Add (new TapGestureRecognizer (OnDeleteClicked)); _shareList.ItemSelected += OnShareSelected; menu.GestureRecognizers.Add (new TapGestureRecognizer (OnMenuClicked)); _shareList.IsPullToRefreshEnabled = true; #endregion #region Main Layout Content = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 0, Padding = new Thickness(0,0,0,0), Children = { _navbar, new BoxView { Color = Color.Gray, HeightRequest = 1, BackgroundColor = Color.Black }, new StackLayout { Padding = new Thickness(0,10,0,0), Children = { header, } }, new ScrollView { Content = _shareList } } }; #endregion }
public NewsListTemplate(IReadOnlyList<NewsFeed> newsFeed) { ItemsSource = newsFeed; VerticalOptions = LayoutOptions.FillAndExpand; BackgroundColor = Theme.BackgroundColor; SeparatorColor = Theme.FrameColor; HasUnevenRows = true; var menuDataTemplate = new DataTemplate(() => { var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); var titleLabel = new Label { VerticalOptions = LayoutOptions.Center, TextColor = Theme.TextColor, FontSize = Device.OnPlatform(16, 20, 16), FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Start }; var publishedLabel = new Label { VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.End, TextColor = Theme.TextColor, FontSize = 12, FontAttributes = FontAttributes.Italic }; var leadLabel = new Label { VerticalOptions = LayoutOptions.Center, TextColor = Theme.TextColor, FontSize = 14, }; var authorLabel = new Label { VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Start, TextColor = Theme.TextColor, FontSize = 14, }; var sourceLabel = new Label { VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.End, TextColor = Theme.TextColor, FontSize = 16, FontAttributes = FontAttributes.Bold }; titleLabel.SetBinding(Label.TextProperty, "Title"); leadLabel.SetBinding(Label.TextProperty, "Lead"); authorLabel.SetBinding(Label.TextProperty, "Author"); sourceLabel.SetBinding(Label.TextProperty, "Source"); publishedLabel.SetBinding(Label.TextProperty, "PublishedString"); grid.Children.Add(titleLabel, 0, 0); grid.Children.Add(publishedLabel, 3, 0); grid.Children.Add(leadLabel, 0, 1); grid.Children.Add(authorLabel, 0, 2); grid.Children.Add(sourceLabel, 2, 2); Grid.SetColumnSpan(titleLabel, 3); Grid.SetColumnSpan(publishedLabel, 1); Grid.SetColumnSpan(leadLabel, 4); Grid.SetColumnSpan(authorLabel, 2); Grid.SetColumnSpan(sourceLabel, 2); var contentFrame = new MarginFrame(5, Theme.BackgroundColor) { Content = new Frame { OutlineColor = Theme.FrameColor, BackgroundColor = Theme.BackgroundColor, VerticalOptions = LayoutOptions.Center, Padding = new Thickness(5), Content = grid, Margin = new Thickness(0, 0, 12, 0), } }; return new ViewCell { View = contentFrame }; }); var cell = new DataTemplate(typeof(ViewCell)); cell.SetBinding(TextCell.TextProperty, "Title"); cell.SetValue(TextCell.TextColorProperty, Color.FromHex("2f4f4f")); ItemTemplate = menuDataTemplate; SelectedItem = newsFeed.Count != 0 ? newsFeed[0] : null; }
Grid CreateScheduleGrid() { var scheduleGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength (1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }, }, BackgroundColor = Color.White }; var listview = new ListView { }; //Don't allow selection listview.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => { listview.SelectedItem = null; }; var itemTemplate = new DataTemplate (typeof(HorizontalCell)); itemTemplate.SetBinding (HorizontalCell.TextProperty, "Day"); itemTemplate.SetValue (HorizontalCell.TextColorProperty, Color.Black); itemTemplate.SetBinding (HorizontalCell.DetailProperty, "HoursOfOperation"); itemTemplate.SetValue (HorizontalCell.DetailColorProperty, Color.Gray); listview.ItemTemplate = itemTemplate; listview.BindingContext = _customMap; listview.SetBinding<CustomMap> (ListView.ItemsSourceProperty, vm => vm.SelectedPin.ScheduleEntries); scheduleGrid.Children.Add (listview, 0, 0); return scheduleGrid; }
View CreateOtherView() { var contentView = new ContentView { BackgroundColor = Color.White }; var listview = new ListView { }; //Don't allow selection listview.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => { var url = e.SelectedItem as Url; if (url != null && url.Value.Contains ("www")) { DependencyService.Get<IPhoneService> ().OpenBrowser (url.Value); } listview.SelectedItem = null; }; var itemTemplate = new DataTemplate (typeof(HorizontalCell)); itemTemplate.SetBinding (HorizontalCell.TextProperty, "Key"); itemTemplate.SetValue (HorizontalCell.TextColorProperty, Color.Black); itemTemplate.SetBinding (HorizontalCell.DetailProperty, "Value"); itemTemplate.SetValue (HorizontalCell.DetailColorProperty, Color.Gray); listview.ItemTemplate = itemTemplate; listview.BindingContext = _customMap; listview.SetBinding<CustomMap> (ListView.ItemsSourceProperty, vm => vm.SelectedPin.Others); contentView.Content = listview; return contentView; }