Beispiel #1
0
        public void ValidateBindableProperties()
        {
            var layout = new StackLayout
            {
                IsPlatformEnabled = true,
            };

            // EmptyView
            object emptyView = new object();

            BindableLayout.SetEmptyView(layout, emptyView);

            Assert.AreEqual(emptyView, BindableLayout.GetEmptyView(layout));
            Assert.AreEqual(emptyView, layout.GetValue(BindableLayout.EmptyViewProperty));

            // EmptyViewTemplateProperty
            DataTemplate emptyViewTemplate = new DataTemplate(typeof(Label));

            BindableLayout.SetEmptyViewTemplate(layout, emptyViewTemplate);

            Assert.AreEqual(emptyViewTemplate, BindableLayout.GetEmptyViewTemplate(layout));
            Assert.AreEqual(emptyViewTemplate, layout.GetValue(BindableLayout.EmptyViewTemplateProperty));


            // ItemsSourceProperty
            IEnumerable itemsSource = new object[0];

            BindableLayout.SetItemsSource(layout, itemsSource);

            Assert.AreEqual(itemsSource, BindableLayout.GetItemsSource(layout));
            Assert.AreEqual(itemsSource, layout.GetValue(BindableLayout.ItemsSourceProperty));

            // ItemTemplateProperty
            DataTemplate itemTemplate = new DataTemplate(typeof(Label));

            BindableLayout.SetItemTemplate(layout, itemTemplate);

            Assert.AreEqual(itemTemplate, BindableLayout.GetItemTemplate(layout));
            Assert.AreEqual(itemTemplate, layout.GetValue(BindableLayout.ItemTemplateProperty));


            // ItemTemplateSelectorProperty
            var itemTemplateSelector = new DataTemplateSelectorFrame();

            BindableLayout.SetItemTemplateSelector(layout, itemTemplateSelector);

            Assert.AreEqual(itemTemplateSelector, BindableLayout.GetItemTemplateSelector(layout));
            Assert.AreEqual(itemTemplateSelector, layout.GetValue(BindableLayout.ItemTemplateSelectorProperty));
        }
Beispiel #2
0
		public void PropertiesAreOnlySetOnMatchingElements()
		{
			var styleString = @"background-color: #ff0000; color: #00ff00;";
			var style = Style.Parse(new CssReader(new StringReader(styleString)), '}');
			Assume.That(style, Is.Not.Null);

			var layout = new StackLayout();
			Assert.That(layout.GetValue(TextElement.TextColorProperty), Is.EqualTo(null));
		}
        private void ToggleStackLayoutDisplay(StackLayout collection, Button button)
        {
            Grid   grid  = (Grid)collection.Parent;
            object rowID = collection.GetValue(Grid.RowProperty);

            GridLength gridLengthShown  = new GridLength(0, GridUnitType.Auto);
            GridLength gridLengthHidden = new GridLength(0, GridUnitType.Absolute);

            if (collection.IsVisible)
            {
                collection.IsVisible = false;
                grid.RowDefinitions[(int)rowID].Height = gridLengthHidden;

                button.Text = "Show";
            }
            else
            {
                collection.IsVisible = true;
                grid.RowDefinitions[(int)rowID].Height = gridLengthShown;

                button.Text = "Hide";
            }
        }
Beispiel #4
0
        /// <summary>
        /// re paint the schedule
        /// </summary>
        private void ArrangeSchedule()
        {
            var schedule = GetSchedule(this);

            if (schedule == null || schedule.ScheduleItemList == null)
            {
                return;
            }

            var list = gridSchedule.Children.Where(m => m.GetType() == typeof(StackLayout)).ToList();

            foreach (var item in list)
            {
                gridSchedule.Children.Remove(item);
            }

            for (int i = 0; i < schedule.ScheduleItemList.Count; i++)
            {
                var item = schedule.ScheduleItemList[i];
                if (item.BeginWeek <= schedule.SelectedWeekIndex + 1 && item.EndWeek >= schedule.SelectedWeekIndex + 1)
                {
                    if (item.Parity != null)
                    {
                        if ((schedule.SelectedWeekIndex + 1) % 2 != item.Parity)
                        {
                            continue;
                        }
                    }
                    StackLayout layout = new StackLayout();
                    layout.Orientation = StackOrientation.Vertical;

                    layout.BackgroundColor = BlockColors[item.CourseId % BlockColors.Count];

                    layout.SetValue(Grid.RowProperty, item.BeginClass);
                    layout.SetValue(Grid.ColumnProperty, item.WeekDay);
                    layout.SetValue(Grid.RowSpanProperty, item.EndClass - item.BeginClass + 1);


                    layout.HorizontalOptions = LayoutOptions.FillAndExpand;
                    layout.BindingContext    = item;

                    Label title = new Label {
                        Text = item.CourseName, FontSize = 10, TextColor = new Color(1, 1, 1), HorizontalOptions = LayoutOptions.CenterAndExpand, HorizontalTextAlignment = TextAlignment.Center
                    };
                    Label room = new Label {
                        Text = item.Room, FontSize = 8, TextColor = new Color(1, 1, 1), HorizontalOptions = LayoutOptions.CenterAndExpand, HorizontalTextAlignment = TextAlignment.Center
                    };

                    layout.Children.Add(title);
                    layout.Children.Add(room);


                    var binding = new Binding();
                    binding.Path = "ItemClickedCommand";
                    binding.Mode = BindingMode.OneWay;

                    layout.BindingContext = this.BindingContext;
                    layout.SetBinding(ClickedCommandProperty, binding);


                    layout.GestureRecognizers.Add(new TapGestureRecognizer {
                        Command = (ICommand)layout.GetValue(ClickedCommandProperty), CommandParameter = item
                    });

                    gridSchedule.Children.Add(layout);
                }
            }
        }