Exemplo n.º 1
0
        public XFListViewPage2()
        {
            var classNames = new[] {
                "Building Cross Platform Apps with Xamarin Part 1",
                "Building Cross Platform Apps with Xamarin Part 2",
                "Building Google Glass Apps with c# and Xamarin",
                "Android for .NET Developers"
            };

            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;
        }
        public ListViewPage()
        {
            Title = "List View Page";

            var listViewData = SampleDataModelFactory.GetSampleData();

            var cell = new DataTemplate(typeof(ImageCell));

            cell.SetValue(ImageCell.TextProperty, "Number");
            cell.SetBinding(ImageCell.DetailProperty, "Number");
            cell.SetValue(ImageCell.ImageSourceProperty, "Hash");

            ListView listView = new ListView {
                ItemTemplate = cell,
                ItemsSource  = listViewData
            };

            listView.ItemTapped += (s, e) => {
                var item = e.Item;
                Insights.Track(Insights_Constants.LIST_VIEW_ITEM_TAPPED, Insights_Constants.LIST_VIEW_ITEM_NUMBER, item.ToString());

                DisplayAlert("Number Tapped", $"You Selected Number {item.ToString()}", "OK");
            };

            Content = listView;
        }
Exemplo n.º 3
0
        public ListViewPage()
        {
            Title = "List View Page";

            var listViewData = SampleDataModelFactory.GetSampleData();

            var cell = new DataTemplate(typeof(WhiteTextImageCell));

            cell.SetValue(TextCell.TextProperty, "Number");
            cell.SetBinding(ImageCell.DetailProperty, "Number");
            cell.SetValue(ImageCell.ImageSourceProperty, "Hash");

            var listView = new ListView
            {
                ItemTemplate    = cell,
                ItemsSource     = listViewData,
                BackgroundColor = Color.FromHex("#2980b9")
            };

            listView.ItemTapped += (s, e) =>
            {
                var item = e.Item;
                AnalyticsHelpers.TrackEvent(AnalyticsConstants.LIST_VIEW_ITEM_TAPPED, new Dictionary <string, string> {
                    { AnalyticsConstants.LIST_VIEW_ITEM_NUMBER, item.ToString() }
                });

                DisplayAlert("Number Tapped", $"You Selected Number {item.ToString()}", "OK");
            };

            Content = listView;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the Chart Styles page.
        /// </summary>
        /// <param name="mainPage">The main page.</param>
        /// <returns>Content Page.</returns>
        private static ContentPage GetChartStylesPage(VisualElement mainPage)
        {
            var controls = new ContentPage
            {
                Title = AppResources.PivotItemSeries,
                Icon  = "bar-chart-32.png"
            };


            var lstControls = new ListView();

            lstControls.ItemsSource     = Variables.SeriesList;
            lstControls.BackgroundColor = Color.FromRgb(255, 255, 255);
            lstControls.RowHeight       = 35;

            Cell = new DataTemplate(typeof(TextCell));

            Cell.SetValue(TextCell.TextColorProperty, Color.Black);
            Cell.SetValue(TextCell.DetailColorProperty, Color.White);

            Cell.SetBinding(TextCell.TextProperty, "Description");
            // Cell.SetBinding(TextCell.DetailProperty, "Summary");

            lstControls.ItemTemplate = Cell;

            lstControls.ItemSelected += async(sender, e) =>
            {
                ElementWrapper obj = e.SelectedItem as ElementWrapper;
                await mainPage.Navigation.PushAsync(new ChartStylesPage(obj.ElementType));
            };

            controls.Content = lstControls;
            return(controls);
        }
 public ChatMessageTemplateSelector(bool showName, bool showImage)
 {
     _rightMessageDataTemplate = new DataTemplate(typeof(RightChatMessageViewCell));
     _leftMessageDataTemplate  = new DataTemplate(typeof(LeftChatMessageViewCell));
     _leftMessageDataTemplate.SetValue(LeftChatMessageViewCell.ShowNameProperty, showName);
     _leftMessageDataTemplate.SetValue(LeftChatMessageViewCell.ShowImageProperty, showImage);
 }
Exemplo n.º 6
0
        public MainPage()
        {
            InitializeComponent();

            _editoras = new List <Editora>
            {
                new Editora {
                    Codigo = 1,
                    Nome   = "novatec",
                    Site   = "www.novatec.com.br"
                },
                new Editora
                {
                    Codigo = 2,
                    Nome   = "Excel Books",
                    Site   = "www.excelbooks.com"
                }
            };

            listViewEditoras.ItemsSource = _editoras;

            var template = new DataTemplate(typeof(TextCell));

            template.SetBinding(TextCell.TextProperty, "Nome");
            template.SetBinding(TextCell.DetailProperty, "Site");
            template.SetValue(TextCell.TextColorProperty, Color.Red);
            template.SetValue(TextCell.DetailColorProperty, Color.Blue);
            listViewEditoras.ItemTemplate = template;

            listViewEditoras.ItemTapped += ListViewEditoras_ItemTapped;
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        private DataTemplate CreateTemplate()
        {
            var cell = new DataTemplate(typeof(TextCell));

            cell.SetBinding(TextCell.TextProperty, "Title");
            cell.SetValue(TextCell.TextColorProperty, Color.White);
            cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent);

            return(cell);
        }
        protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
        {
            var listView = container as ListView;
            var dataGrid = listView.Parent as DataGrid;

            _dataGridRowTemplate.SetValue(DataGridViewCell.DataGridProperty, dataGrid);
            _dataGridRowTemplate.SetValue(DataGridViewCell.IndexProperty, listView.ItemsSource.Cast <object>().ToList().IndexOf(item));

            return(_dataGridRowTemplate);
        }
Exemplo n.º 11
0
        private async Task <StackLayout> _createCampaignLayout(CampaignViewModel viewModel)
        {
            var fullName   = string.Format("{0} {1}", viewModel.CamapignUser.FirstName, viewModel.CamapignUser.LastName);
            var createdStr = String.Format("Created {0}", viewModel.Model.CreatedAt.ToString("D"));

            var campaignCreatorCell = new DataTemplate(typeof(ImageCell));

            campaignCreatorCell.SetValue(TextCell.TextProperty, fullName);
            campaignCreatorCell.SetValue(TextCell.DetailProperty, createdStr);
            var campaignCreatorList = new List <CampaignViewModel>
            {
                viewModel
            };

            var campaignCreatorView = new ListView {
                ItemsSource = campaignCreatorList, ItemTemplate = campaignCreatorCell, BackgroundColor = Color.White, RowHeight = 60, MinimumHeightRequest = 60
            };

            var campaignDesc = new Label
            {
                Text            = viewModel.Model.Description,
                TextColor       = Color.White,
                Font            = Font.SystemFontOfSize(NamedSize.Large),
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            var campaignProgressBar = new ProgressBar();

            if (viewModel.Model.TargetAmount != null)
            {
                var campaignProgress = (double)(viewModel.Model.DonationAmount / viewModel.Model.TargetAmount);
                campaignProgressBar.SetValue(ProgressBar.ProgressProperty, campaignProgress);
            }



            var campaignView = new StackLayout
            {
                BackgroundColor = Helpers.Color.DarkGray.ToFormsColor(),
                Padding         = new Thickness(10, 10, 10, 20),
                Children        =
                {
                    campaignCreatorView,
                    campaignDesc,
                    campaignProgressBar
                }
            };

            return(campaignView);
        }
        protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
        {
            var self = (StackList)container;

            // Create row
            Template.SetValue(Row.DataGridProperty, self.DataGrid);
            
            // Passing value context
            Template.SetValue(Row.BindingContextProperty, item);

            //Template.SetValue(Row.RowContextProperty, item);

            return Template;
        }
Exemplo n.º 13
0
        public MenuPage()
        {
            menuItems.Add(new USAIDMenuItem {
                Title = AppResources.HomeMenuText, Padding = ""
            });
            menuItems.Add(new USAIDMenuItem {
                Title = AppResources.SitesMenuText, Padding = ""
            });
            //menuItems.Add(new USAIDMenuItem { Title="Help", Padding=""});
            menuItems.Add(new USAIDMenuItem {
                Title = AppResources.AboutMenuText, Padding = ""
            });
            //menuItems.Add(new USAIDMenuItem { Title = "Settings", Padding = "" });
            menuItems.Add(new USAIDMenuItem {
                Title = AppResources.LogOutMenuText, Padding = ""
            });

            BackgroundColor = Color.FromHex("333333");

            var layout = new StackLayout {
                Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand
            };

            var stackLayoutSpacer = new StackLayout();

            stackLayoutSpacer.HeightRequest = 20;
            layout.Children.Add(stackLayoutSpacer);


            Menu = new ListView {
                ItemsSource     = menuItems,
                VerticalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.Transparent,
            };

            var cell = new DataTemplate(typeof(Custom.MenuCell));

            cell.SetBinding(TextCell.TextProperty, "Title");
            cell.SetBinding(TextCell.TextProperty, "Padding");

            cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent);
            cell.SetValue(TextCell.TextColorProperty, Color.FromHex("AAAAAA"));


            Menu.ItemTemplate = cell;

            layout.Children.Add(Menu);

            Content = layout;
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        public MainPage()
        {
            InitializeComponent();
            DataTemplate dt = new DataTemplate(typeof(TextCell));

            dt.SetBinding(TextCell.TextProperty, new Binding("Text"));
            dt.SetBinding(TextCell.DetailProperty, new Binding("Date"));
            dt.SetValue(TextCell.TextColorProperty, Color.Blue);
            listView.ItemTemplate = dt;

            listView.ItemSelected += ListView_ItemSelected;
            addButton.Clicked     += AddButton_Clicked;

            // in this case, we send a string to debug where the mssage is coming form the messaing center
            // reload, deleted, added, edited so we'll need this message several times
            MessagingCenter.Subscribe <String>(this, "ModifiedMessage", (sender) =>
            {
                this.ReloadlistData();
                // because I want to have more control, I wawnt to figure where this message is coming from.
                // use a debug message
                Debug.WriteLine(sender);
            });

            // reload list data so that when user leaves app and comes back, the data is still there.
            this.ReloadlistData();
        }
Exemplo n.º 16
0
        public MenuPage()
        {
            BindingContext  = this;
            Title           = "Menu";
            BackgroundColor = AppStyle.Menu.BACKGROUND_COLOR;
            List <MenuItem> menuItems = new List <MenuItem> {
                new MenuItem {
                    Type = MenuItemType.Play
                },
                new MenuItem {
                    Type = MenuItemType.Balls
                }
            };
            DataTemplate it = new DataTemplate(typeof(TextCell));

            it.SetBinding(TextCell.TextProperty, "Title");
            it.SetValue(TextCell.TextColorProperty, AppStyle.Menu.ITEM_TEXT_COLOR);
            ListView listV = new ListView {
                BackgroundColor = AppStyle.Menu.LIST_BACKGROUND_COLOR,
                ItemsSource     = menuItems,
                ItemTemplate    = it,
                Footer          = new BoxView {
                    BackgroundColor = AppStyle.Menu.LIST_BACKGROUND_COLOR
                }
            };

            listV.ItemTapped += (object sender, ItemTappedEventArgs e) => {
                MenuItem selItem = (MenuItem)e.Item;
                App.SetDetailPage(selItem.Type);
                listV.SelectedItem = null;
            };
            Content = listV;
        }
        protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
        {
            var listView = container as ListView;
            var dataGrid = listView.Parent as DataGrid;
            var items    = dataGrid.InternalItems;

            _dataGridRowTemplate.SetValue(DataGridViewCell.DataGridProperty, dataGrid);
            _dataGridRowTemplate.SetValue(DataGridViewCell.RowContextProperty, item);

            if (items != null)
            {
                _dataGridRowTemplate.SetValue(DataGridViewCell.IndexProperty, items.IndexOf(item));
            }

            return(_dataGridRowTemplate);
        }
Exemplo n.º 18
0
        private ListView CreateMatchesListView()
        {
            var cell = new DataTemplate(typeof(TextCell));

            cell.SetBinding(TextCell.TextProperty, "Title");
            cell.SetValue(TextCell.TextColorProperty, Color.Black);

            //cell.SetValue(TextCell.TextProperty, Font.SystemFontOfSize(NamedSize.Micro));

            var listView = new ListView
            {
                RowHeight    = 40,
                ItemTemplate = cell
            };

            listView.ItemTemplate.SetBinding(TextCell.TextProperty, "Title");
            listView.ItemTapped += async(sender, e) =>
            {
                var soccerEvent = (SoccerEvent)e.Item;
                var detailsPage = new DetailsPage(soccerEvent.EventId);
                await Navigation.PushAsync(detailsPage);
            };

            var soccerEvents = new SoccerEventsService().Get();

            soccerEvents.ContinueWith((task) =>
            {
                listView.ItemsSource = task.Result;
            },
                                      TaskScheduler.FromCurrentSynchronizationContext());

            return(listView);
        }
Exemplo n.º 19
0
        public masterPage()
        {
            // Creating list of items class
            List <Items> list = new List <Items>
            {
                new Items("First Item"),
                new Items("Second Item"),
                new Items("Third Item"),
                new Items("Fourth Item"),
            };

            // Populating items into ListView
            ListView listView = new ListView();
            var      Template = new DataTemplate(typeof(TextCell));

            Template.SetBinding(TextCell.TextProperty, "Name");
            Template.SetValue(TextCell.TextColorProperty, Color.White);
            listView.ItemTemplate        = Template;
            listView.ItemsSource         = list;
            listView.RowHeight           = 70;
            listView.SeparatorColor      = Color.White;
            listView.SeparatorVisibility = SeparatorVisibility.Default;

            // Declaring the Master property of the MasterDetailPage
            this.Master = new ContentPage
            {
                Title           = "MedTexterApp",
                Content         = listView,
                BackgroundColor = Color.Transparent
            };

            // Setting the DetailPage to the Detail Property of the MasterDetailPage
            this.Detail = new NavigationPage(new detailpage());
        }
Exemplo n.º 20
0
        public Result(string cod, string name, string position)
        {
            InitializeComponent();

            var template = new DataTemplate(typeof(TextCell));

            template.SetValue(TextCell.TextColorProperty, Color.Black);
            template.SetBinding(TextCell.TextProperty, ".");
            lv1.ItemTemplate = template;

            try
            {
                Services.HttpService.SearchAsync(cod, name, position).ContinueWith(x => {
                    list = x.Result;
                    foreach (var item in list)
                    {
                        names.Add(item["name"].ToString());
                    }
                });
            }
            catch (Exception e)
            {
                DisplayAlert("Erro", e.Message, "OK");
            }
            lv1.ItemsSource = names;
        }
Exemplo n.º 21
0
        public MainPage()
        {
            InitializeComponent();


            DataTemplate cell2 = new DataTemplate(typeof(ImageCell));

            cell2.SetBinding(ImageCell.TextProperty, "Text");
            cell2.SetBinding(ImageCell.DetailProperty, "Detail");
            cell2.SetBinding(ImageCell.ImageSourceProperty, "Icon");
            cell2.SetValue(ImageCell.TextColorProperty, Color.Green);

            listView = new ListView
            {
                RowHeight      = 60 //Cellの高さを設定
                , ItemTemplate = cell2
            };
            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        = { listView }
            };

            fetchArticles(new GetExchangeAPI());

            listView.ItemSelected += async(sender, e) => {
                var tmp = new Data();
                tmp     = (Data)e.SelectedItem;
                Country = tmp.Text.Substring(0, 3);
                fetchArticles(new GetExchangeAPI());
            };
        }
Exemplo n.º 22
0
		public void On()
		{
			var template = new DataTemplate (typeof (SwitchCell));
			template.SetValue (SwitchCell.OnProperty, true);

			SwitchCell cell = (SwitchCell)template.CreateContent();
			Assert.That (cell.On, Is.EqualTo (true));
		}
Exemplo n.º 23
0
		public void Text()
		{
			var template = new DataTemplate (typeof (SwitchCell));
			template.SetValue (SwitchCell.TextProperty, "text");			

			SwitchCell cell = (SwitchCell)template.CreateContent();
			Assert.That (cell.Text, Is.EqualTo ("text"));
		}
Exemplo n.º 24
0
        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;
        }
Exemplo n.º 25
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",
                }
            };

            Label lbl = (Xamarin.Forms.Label)label.Content;

            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                lbl.FontSize = Device.GetNamedSize(NamedSize.Micro, lbl);
                break;

            case Device.Android:
                lbl.FontSize = Device.GetNamedSize(NamedSize.Medium, lbl);
                break;
            }

            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(ImageCell.ImageSourceProperty, "IconSource");
            cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent);

            Menu.ItemTemplate = cell;

            layout.Children.Add(Menu);

            Content = layout;
        }
Exemplo n.º 26
0
        public void Text()
        {
            var template = new DataTemplate(typeof(TextCell));

            template.SetValue(TextCell.TextProperty, "text");

            TextCell cell = (TextCell)template.CreateContent();

            Assert.That(cell.Text, Is.EqualTo("text"));
        }
Exemplo n.º 27
0
        public void Detail()
        {
            var template = new DataTemplate(typeof(TextCell));

            template.SetValue(TextCell.DetailProperty, "detail");

            TextCell cell = (TextCell)template.CreateContent();

            Assert.That(cell.Detail, Is.EqualTo("detail"));
        }
Exemplo n.º 28
0
        public void On()
        {
            var template = new DataTemplate(typeof(SwitchCell));

            template.SetValue(SwitchCell.OnProperty, true);

            SwitchCell cell = (SwitchCell)template.CreateContent();

            Assert.That(cell.On, Is.EqualTo(true));
        }
Exemplo n.º 29
0
        public DayTemplatePage(int day)
        {
            _day            = day;
            BackgroundColor = Color.FromHex("ecf0f1");
            Title           = "Day " + day;

            _viewModel     = new SessionViewModel(new ThatConfService(new System.Net.Http.HttpClient()));
            BindingContext = _viewModel;

            var stackLayout = new StackLayout {
            };

            var sessionListView = new ListView()
            {
                BackgroundColor = Color.White,
            };

            var sessionItemTemplate = new DataTemplate(typeof(ImageCell));

            sessionItemTemplate.SetBinding(ImageCell.TextProperty, "Title");
            sessionItemTemplate.SetValue(ImageCell.TextColorProperty, Color.FromHex("ae3814"));
            sessionItemTemplate.SetBinding(ImageCell.DetailProperty, "Description");
            sessionItemTemplate.SetValue(ImageCell.DetailColorProperty, Color.Black);
            sessionItemTemplate.SetBinding(ImageCell.ImageSourceProperty, "ImageUrl");


            sessionListView.ItemTemplate   = sessionItemTemplate;
            sessionListView.BindingContext = _viewModel;
            sessionListView.SetBinding <SessionViewModel> (ListView.ItemsSourceProperty, vm => vm.SessionList);

            var slider = new Slider();

            //From 5 am to 10 pm
            slider.Maximum = 22.0;
            slider.Minimum = 5.0;
            slider.SetBinding <SessionViewModel> (Slider.ValueProperty, vm => vm.Hour, BindingMode.TwoWay);

            stackLayout.Children.Add(sessionListView);
            stackLayout.Children.Add(slider);

            Content = stackLayout;
        }
Exemplo n.º 30
0
        public MenuPage()
        {
            Title = "Menu";
            Icon  = "ic_menu.png";

            this.BackgroundColor = Color.FromHex("#33302e");
            Padding = new Thickness(10, 20);

            var categories = new List <MenuCategory>()
            {
                new MenuCategory("Dashboard", () => new DashboardPage()),
                new MenuCategory("Report List", () => new MainReportPage()),
                new MenuCategory("Sign Out", () => new AltiusDashboardPage()),
            };

            var dataTemplate = new DataTemplate(typeof(TextCell));

            dataTemplate.SetBinding(TextCell.TextProperty, "Name");
            dataTemplate.SetValue(TextCell.TextColorProperty, Color.White);

            var listView = new ListView()
            {
                ItemsSource     = categories,
                ItemTemplate    = dataTemplate,
                SeparatorColor  = Color.FromHex("#888888"),
                BackgroundColor = Color.FromHex("#33302e")
            };

            //listView.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => {
            //    if (OnMenuSelect != null)
            //    {
            //        var menuCategory = (MenuCategory)e.SelectedItem;
            //        var menuName = menuCategory.Name;
            //        var categoryPage = menuCategory.PageFn();
            //        OnMenuSelect(menuName, categoryPage);
            //    }
            //};

            listView.ItemTapped += (sender, e) =>
            {
                if (OnMenuSelect != null)
                {
                    var menuCategory = ((ListView)sender).SelectedItem as MenuCategory;
                    var menuName     = menuCategory.Name;
                    var categoryPage = menuCategory.PageFn();

                    OnMenuSelect(menuName, categoryPage);

                    ((ListView)sender).SelectedItem = null;
                }
            };

            Content = listView;
        }
Exemplo n.º 31
0
            DataTemplate CreateTemplate(Type itemType, BindableObject container)
            {
                var dataTemplate = new DataTemplate(typeof(ItemView));

                Color color;

                if (!m_colorByType.TryGetValue(itemType, out color))
                {
                    color = Color.Pink;
                    dataTemplate.SetValue(BackgroundColorProperty, Color.Black);
                }
                else
                {
                    dataTemplate.SetValue(BackgroundColorProperty, Color.Blue);
                }

                dataTemplate.SetValue(ItemView.TextColorProperty, color);
                dataTemplate.SetValue(ItemView.ContextProperty, container);
                return(dataTemplate);
            }
Exemplo n.º 32
0
        public EducationPage(AppUser user)
        {
            InitializeComponent();
            User = user;
            this.BindingContext = new EducationContentViewModel();
            var template = new DataTemplate(typeof(TextCell));

            template.SetValue(TextCell.TextColorProperty, Color.DeepSkyBlue);
            template.SetBinding(TextCell.TextProperty, ".");
            listView.ItemTemplate = template;
        }
Exemplo n.º 33
0
		public void SetBindingOverridesValue()
		{
			var template = new DataTemplate (typeof (MockBindable));
			template.SetValue (MockBindable.TextProperty, "value");
			template.SetBinding (MockBindable.TextProperty, new Binding ("."));

			MockBindable bindable = (MockBindable) template.CreateContent();
			Assume.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo (bindable.BindingContext));

			bindable.BindingContext = "binding";
			Assert.That (bindable.GetValue (MockBindable.TextProperty), Is.EqualTo ("binding"));
		}
Exemplo n.º 34
0
		public void Detail ()
		{
			var template = new DataTemplate (typeof (TextCell));
			template.SetValue (TextCell.DetailProperty, "detail");

			TextCell cell = (TextCell)template.CreateContent ();
			Assert.That (cell.Detail, Is.EqualTo ("detail"));
		}
Exemplo n.º 35
0
		public void SetValueInvalid()
		{
			var template = new DataTemplate (typeof (MockBindable));
			Assert.That (() => template.SetValue (null, "string"), Throws.InstanceOf<ArgumentNullException>());
		}