Beispiel #1
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var hasShadowContainer = new StateViewContainer <Frame> (Test.Frame.HasShadow, new Frame {
                HasShadow = true
            });
            var outlineColorContainer = new StateViewContainer <Frame> (Test.Frame.OutlineColor, new Frame {
                BorderColor = Color.Teal,
            });
            var viewContainer = new StateViewContainer <Frame> (Test.Frame.Content, new Frame {
                BorderColor = Color.Teal,
                Content     = new Label {
                    Text = "I am a frame"
                }
            });
            var cornerRadiusContainer = new StateViewContainer <Frame>(Test.Frame.CornerRadius, new Frame {
                BorderColor  = Color.Teal,
                CornerRadius = 25
            });

            Add(hasShadowContainer);
            Add(outlineColorContainer);
            Add(viewContainer);
            Add(cornerRadiusContainer);
        }
Beispiel #2
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var aspectFillContainer = new ViewContainer <Image> (Test.Image.AspectFill, new Image {
                Aspect = Aspect.AspectFill
            });
            var aspectFitContainer = new ViewContainer <Image> (Test.Image.AspectFit, new Image {
                Aspect = Aspect.AspectFit
            });
            var fillContainer = new ViewContainer <Image> (Test.Image.Fill, new Image {
                Aspect = Aspect.Fill
            });
            var isLoadingContainer = new StateViewContainer <Image> (Test.Image.IsLoading, new Image());
            var isOpaqueContainer  = new StateViewContainer <Image> (Test.Image.IsOpaque, new Image());

            InitializeElement(aspectFillContainer.View);
            InitializeElement(aspectFitContainer.View);
            InitializeElement(fillContainer.View);
            InitializeElement(isLoadingContainer.View);
            InitializeElement(isOpaqueContainer.View);

            var sourceContainer = new ViewContainer <Image> (Test.Image.Source, new Image {
                Source = "https://raw.githubusercontent.com/xamarin/Xamarin.Forms/main/Xamarin.Forms.Controls/coffee.png"
            });

            Add(aspectFillContainer);
            Add(aspectFitContainer);
            Add(fillContainer);
            Add(isLoadingContainer);
            Add(isOpaqueContainer);
            Add(sourceContainer);
        }
Beispiel #3
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var hasShadowContainer = new StateViewContainer <Frame>(Test.Frame.HasShadow, new Frame {
                HasShadow = true
            });

            hasShadowContainer.StateChangeButton.Command = new Command(() => hasShadowContainer.View.HasShadow = !hasShadowContainer.View.HasShadow);

            var viewContainer = new StateViewContainer <Frame>(Test.Frame.Content, new Frame
            {
                BorderColor = Color.Teal,
                Content     = new Label {
                    Text = "I am a frame"
                }
            });

            viewContainer.StateChangeButton.Command = new Command(() => viewContainer.View.Content = new Label {
                Text = "Different content"
            });

            var cornerRadiusContainer = new StateViewContainer <Frame>(Test.Frame.CornerRadius, new Frame
            {
                BorderColor  = Color.Teal,
                CornerRadius = 25
            });

            cornerRadiusContainer.StateChangeButton.Command = new Command(() => cornerRadiusContainer.View.CornerRadius = _randomValue.Next(0, 25));

            Add(hasShadowContainer);
            Add(viewContainer);
            Add(cornerRadiusContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var aspectFillContainer = new ViewContainer <Image> (Test.Image.AspectFill, new Image {
                Aspect = Aspect.AspectFill
            });
            var aspectFitContainer = new ViewContainer <Image> (Test.Image.AspectFit, new Image {
                Aspect = Aspect.AspectFit
            });
            var fillContainer = new ViewContainer <Image> (Test.Image.Fill, new Image {
                Aspect = Aspect.Fill
            });
            var isLoadingContainer = new StateViewContainer <Image> (Test.Image.IsLoading, new Image());
            var isOpaqueContainer  = new StateViewContainer <Image> (Test.Image.IsOpaque, new Image());

            InitializeElement(aspectFillContainer.View);
            InitializeElement(aspectFitContainer.View);
            InitializeElement(fillContainer.View);
            InitializeElement(isLoadingContainer.View);
            InitializeElement(isOpaqueContainer.View);

            var sourceContainer = new ViewContainer <Image> (Test.Image.Source, new Image {
                Source = "http://sethrosetter.com/images/projects/bezierdraw/bezierdraw_5.jpg"
            });

            Add(aspectFillContainer);
            Add(aspectFitContainer);
            Add(fillContainer);
            Add(isLoadingContainer);
            Add(isOpaqueContainer);
            Add(sourceContainer);
        }
Beispiel #5
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var colorContainer = new ViewContainer <ActivityIndicator> (Test.ActivityIndicator.Color, new ActivityIndicator {
                Color     = Color.Lime,
                IsRunning = true
            });

            var isRunningContainer = new StateViewContainer <ActivityIndicator> (Test.ActivityIndicator.IsRunning, new ActivityIndicator {
                IsRunning = true
            });

            isRunningContainer.StateChangeButton.Clicked += (sender, args) => {
                isRunningContainer.View.IsRunning = !isRunningContainer.View.IsRunning;
            };

            Add(colorContainer);
            Add(isRunningContainer);
        }
Beispiel #6
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);


            IsEnabledStateViewContainer.View.Clicked += (sender, args) =>
            {
                IsEnabledStateViewContainer.TitleLabel.Text += " (Tapped)";
            };

            var aspectFillContainer = new ViewContainer <ImageButton>(Test.ImageButton.AspectFill, new ImageButton {
                Aspect = Aspect.AspectFill
            });
            var aspectFitContainer = new ViewContainer <ImageButton>(Test.ImageButton.AspectFit, new ImageButton {
                Aspect = Aspect.AspectFit
            });
            var fillContainer = new ViewContainer <ImageButton>(Test.ImageButton.Fill, new ImageButton {
                Aspect = Aspect.Fill
            });
            var isLoadingContainer = new StateViewContainer <ImageButton>(Test.ImageButton.IsLoading, new ImageButton());
            var isOpaqueContainer  = new StateViewContainer <ImageButton>(Test.ImageButton.IsOpaque, new ImageButton());


            var borderButtonContainer = new ViewContainer <ImageButton>(Test.ImageButton.BorderColor,
                                                                        new ImageButton
            {
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Red,
                BorderWidth     = 1,
                Source          = "oasissmall.jpg"
            }
                                                                        );

            var corderRadiusContainer = new ViewContainer <ImageButton>(Test.ImageButton.CornerRadius,
                                                                        new ImageButton
            {
                Source          = "oasissmall.jpg",
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Red,
                CornerRadius    = 20,
                BorderWidth     = 1,
            }
                                                                        );

            var borderWidthContainer = new ViewContainer <ImageButton>(Test.ImageButton.BorderWidth,
                                                                       new ImageButton
            {
                Source          = "oasissmall.jpg",
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Red,
                BorderWidth     = 15,
            }
                                                                       );

            var clickedContainer = new EventViewContainer <ImageButton>(Test.ImageButton.Clicked,
                                                                        new ImageButton
            {
                Source = "oasissmall.jpg"
            }
                                                                        );

            clickedContainer.View.Clicked += (sender, args) => clickedContainer.EventFired();

            var pressedContainer = new EventViewContainer <ImageButton>(Test.ImageButton.Pressed,
                                                                        new ImageButton
            {
                Source = "oasissmall.jpg"
            }
                                                                        );

            pressedContainer.View.Pressed += (sender, args) => pressedContainer.EventFired();

            var commandContainer = new ViewContainer <ImageButton>(Test.ImageButton.Command,
                                                                   new ImageButton
            {
                Command = new Command(() => DisplayActionSheet("Hello Command", "Cancel", "Destroy")),
                Source  = "oasissmall.jpg"
            }
                                                                   );

            var imageContainer = new ViewContainer <ImageButton>(Test.ImageButton.Image,
                                                                 new ImageButton
            {
                Source = new FileImageSource {
                    File = "bank.png"
                }
            }
                                                                 );

            var paddingContainer = new ViewContainer <ImageButton>(Test.ImageButton.Padding,
                                                                   new ImageButton
            {
                Source          = "oasissmall.jpg",
                BackgroundColor = Color.Red,
                Padding         = new Thickness(20, 30, 60, 15)
            }
                                                                   );


            InitializeElement(aspectFillContainer.View);
            InitializeElement(aspectFitContainer.View);
            InitializeElement(fillContainer.View);
            InitializeElement(isLoadingContainer.View);
            InitializeElement(isOpaqueContainer.View);

            var sourceContainer = new ViewContainer <ImageButton>(Test.ImageButton.Source, new ImageButton {
                Source = "https://raw.githubusercontent.com/xamarin/Xamarin.Forms/master/Xamarin.Forms.Controls/coffee.png"
            });

            var gifContainer = new ViewContainer <ImageButton>(Test.ImageButton.Source, new ImageButton {
                Source = "GifTwo.gif"
            });

            Add(aspectFillContainer);
            Add(aspectFitContainer);
            Add(fillContainer);
            Add(isLoadingContainer);
            Add(isOpaqueContainer);
            Add(sourceContainer);
            Add(gifContainer);

            Add(borderButtonContainer);
            Add(borderWidthContainer);
            Add(clickedContainer);
            Add(commandContainer);
            Add(corderRadiusContainer);
            Add(imageContainer);
            Add(pressedContainer);
            Add(paddingContainer);
        }
Beispiel #7
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var viewModel = new ListViewViewModel();

            var groupDisplayBindingContainer = new ViewContainer <ListView>(Test.ListView.GroupDisplayBinding, new ListView());

            InitializeElement(groupDisplayBindingContainer.View);
            groupDisplayBindingContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            groupDisplayBindingContainer.View.IsGroupingEnabled   = true;
            groupDisplayBindingContainer.View.GroupDisplayBinding = new Binding("Key");


            var groupHeaderTemplateContainer = new ViewContainer <ListView>(Test.ListView.GroupHeaderTemplate, new ListView());

            InitializeElement(groupHeaderTemplateContainer.View);
            groupHeaderTemplateContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            groupHeaderTemplateContainer.View.IsGroupingEnabled   = true;
            groupHeaderTemplateContainer.View.GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell));

            var groupShortNameContainer = new ViewContainer <ListView>(Test.ListView.GroupShortNameBinding, new ListView());

            InitializeElement(groupShortNameContainer.View);
            groupShortNameContainer.View.ItemsSource           = viewModel.CategorizedEmployees;
            groupShortNameContainer.View.IsGroupingEnabled     = true;
            groupShortNameContainer.View.GroupShortNameBinding = new Binding("Key");

            // TODO - not sure how to do this
            var hasUnevenRowsContainer = new ViewContainer <ListView>(Test.ListView.HasUnevenRows, new ListView());

            InitializeElement(hasUnevenRowsContainer.View);
            hasUnevenRowsContainer.View.HasUnevenRows = true;
            hasUnevenRowsContainer.View.ItemTemplate  = new DataTemplate(typeof(UnevenCell));

            var isGroupingEnabledContainer = new StateViewContainer <ListView>(Test.ListView.IsGroupingEnabled, new ListView());

            InitializeElement(isGroupingEnabledContainer.View);
            isGroupingEnabledContainer.View.ItemsSource           = viewModel.CategorizedEmployees;
            isGroupingEnabledContainer.View.IsGroupingEnabled     = true;
            isGroupingEnabledContainer.StateChangeButton.Clicked += (sender, args) => isGroupingEnabledContainer.View.IsGroupingEnabled = !isGroupingEnabledContainer.View.IsGroupingEnabled;


            var itemAppearingContainer = new EventViewContainer <ListView>(Test.ListView.ItemAppearing, new ListView());

            InitializeElement(itemAppearingContainer.View);
            itemAppearingContainer.View.ItemAppearing += (sender, args) => itemAppearingContainer.EventFired();

            var itemDisappearingContainer = new EventViewContainer <ListView>(Test.ListView.ItemDisappearing, new ListView());

            InitializeElement(itemDisappearingContainer.View);
            itemDisappearingContainer.View.ItemDisappearing += (sender, args) => itemDisappearingContainer.EventFired();

            var itemSelectedContainer = new EventViewContainer <ListView>(Test.ListView.ItemSelected, new ListView());

            InitializeElement(itemSelectedContainer.View);
            itemSelectedContainer.View.ItemSelected += (sender, args) => itemSelectedContainer.EventFired();

            var itemTappedContainer = new EventViewContainer <ListView>(Test.ListView.ItemTapped, new ListView());

            InitializeElement(itemTappedContainer.View);
            itemTappedContainer.View.ItemTapped += (sender, args) => itemTappedContainer.EventFired();

            // TODO
            var rowHeightContainer = new ViewContainer <ListView>(Test.ListView.RowHeight, new ListView());

            InitializeElement(rowHeightContainer.View);

            var selectedItemContainer = new ViewContainer <ListView>(Test.ListView.SelectedItem, new ListView());

            InitializeElement(selectedItemContainer.View);
            selectedItemContainer.View.SelectedItem = viewModel.Employees[2];

            var fastScrollItemContainer = new ViewContainer <ListView>(Test.ListView.FastScroll, new ListView());

            InitializeElement(fastScrollItemContainer.View);
            fastScrollItemContainer.View.On <Android>().SetIsFastScrollEnabled(true);
            fastScrollItemContainer.View.ItemsSource = viewModel.CategorizedEmployees;
        protected virtual void Build(StackLayout stackLayout)
        {
            var isFocusedView = new T();

            isFocusedView.SetValueCore(IsFocusedPropertyKey, true);

            IsEnabledStateViewContainer = new StateViewContainer <T>(Test.VisualElement.IsEnabled, new T {
                IsEnabled = true
            });
            IsEnabledStateViewContainer.StateChangeButton.Command = new Command(() =>
            {
                IsEnabledStateViewContainer.View.IsEnabled = !IsEnabledStateViewContainer.View.IsEnabled;
            });

            var isVisibleStateViewContainer = new StateViewContainer <T>(Test.VisualElement.IsVisible, new T {
                IsVisible = true
            });

            isVisibleStateViewContainer.StateChangeButton.Command = new Command(() =>
            {
                isVisibleStateViewContainer.View.IsVisible = !isVisibleStateViewContainer.View.IsVisible;
            });

            var isFocusedStateViewContainer = new StateViewContainer <T>(Test.VisualElement.IsFocused, isFocusedView);

            isFocusedStateViewContainer.StateChangeButton.Command = new Command(() =>
            {
                if ((bool)isFocusedView.GetValue(VisualElement.IsFocusedProperty))
                {
                    isFocusedView.SetValueCore(IsFocusedPropertyKey, false);
                }
                else
                {
                    isFocusedView.SetValueCore(IsFocusedPropertyKey, true);
                }
            });

            var focusStateViewContainer = new StateViewContainer <T>(Test.VisualElement.Focus, new T());

            focusStateViewContainer.StateChangeButton.Command = new Command(() =>
            {
                if (focusStateViewContainer.View.IsFocused)
                {
                    focusStateViewContainer.View.Unfocus();
                }
                else
                {
                    focusStateViewContainer.View.Focus();
                }
            });

            var focusedEventViewContainer = new EventViewContainer <T>(Test.VisualElement.Focused, new T());

            focusedEventViewContainer.View.Focused += (sender, args) => focusedEventViewContainer.EventFired();

            var unfocusedEventViewContainer = new EventViewContainer <T>(Test.VisualElement.Unfocused, new T());

            unfocusedEventViewContainer.View.Unfocused += (sender, args) => unfocusedEventViewContainer.EventFired();

            var gestureRecognizerEventViewContainer = new EventViewContainer <T>(Test.View.GestureRecognizers, new T());

            gestureRecognizerEventViewContainer.View.GestureRecognizers.Add(
                new TapGestureRecognizer
            {
                Command = new Command(() => gestureRecognizerEventViewContainer.EventFired())
            }
                );

            _viewContainers = new List <ViewContainer <T> > {
                isFocusedStateViewContainer,
                new ViewContainer <T> (Test.VisualElement.BackgroundColor, new T {
                    BackgroundColor = Color.Blue
                }),
                focusStateViewContainer,
                gestureRecognizerEventViewContainer,
                new LayeredViewContainer <T> (Test.VisualElement.InputTransparent, new T {
                    InputTransparent = true
                }),
                IsEnabledStateViewContainer,
                focusedEventViewContainer,
                unfocusedEventViewContainer,
                isVisibleStateViewContainer,
                new ViewContainer <T> (Test.VisualElement.Opacity, new T {
                    Opacity = 0.5
                }),
                new ViewContainer <T> (Test.VisualElement.Rotation, new T {
                    Rotation = 10
                }),
                new ViewContainer <T> (Test.VisualElement.RotationX, new T {
                    RotationX = 33
                }),
                new ViewContainer <T> (Test.VisualElement.RotationY, new T {
                    RotationY = 10
                }),
                new ViewContainer <T> (Test.VisualElement.Scale, new T {
                    Scale = 0.5
                }),
                new ViewContainer <T> (Test.VisualElement.TranslationX, new T {
                    TranslationX = 30
                }),
                new ViewContainer <T> (Test.VisualElement.TranslationY, new T {
                    TranslationY = 30
                }),
            };

            _layout = new StackLayout();

            _targetEntry = new Entry {
                AutomationId = "TargetViewContainer", Placeholder = "Jump To ViewContainer"
            };

            var goButton = new Button
            {
                Text         = "Go",
                AutomationId = "GoButton"
            };

            goButton.Clicked += GoClicked;

            _picker = new Picker();
            foreach (var container in _viewContainers)
            {
                _picker.Items.Add(container.TitleLabel.Text);
            }

            _picker.SelectedIndex = _currentIndex;

            _picker.SelectedIndexChanged += PickerSelectedIndexChanged;

            _layout.Children.Add(_picker);
            _layout.Children.Add(_targetEntry);
            _layout.Children.Add(goButton);
            _layout.Children.Add(_viewContainers[_currentIndex].ContainerLayout);

            stackLayout.Children.Add(_layout);

            if (!SupportsFocus)
            {
                stackLayout.Children.Remove(focusStateViewContainer.ContainerLayout);
                stackLayout.Children.Remove(isFocusedStateViewContainer.ContainerLayout);
            }

            if (!SupportsTapGestureRecognizer)
            {
                stackLayout.Children.Remove(gestureRecognizerEventViewContainer.ContainerLayout);
            }

            foreach (var element in _viewContainers)
            {
                InitializeElement(element.View);
            }
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var viewModel = new ListViewViewModel();

            var groupDisplayBindingContainer = new ViewContainer <ListView>(Test.ListView.GroupDisplayBinding, new ListView());

            InitializeElement(groupDisplayBindingContainer.View);
            groupDisplayBindingContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            groupDisplayBindingContainer.View.IsGroupingEnabled   = true;
            groupDisplayBindingContainer.View.GroupDisplayBinding = new Binding("Key");


            var groupHeaderTemplateContainer = new ViewContainer <ListView>(Test.ListView.GroupHeaderTemplate, new ListView());

            InitializeElement(groupHeaderTemplateContainer.View);
            groupHeaderTemplateContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            groupHeaderTemplateContainer.View.IsGroupingEnabled   = true;
            groupHeaderTemplateContainer.View.GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell));

            var groupShortNameContainer = new ViewContainer <ListView>(Test.ListView.GroupShortNameBinding, new ListView());

            InitializeElement(groupShortNameContainer.View);
            groupShortNameContainer.View.ItemsSource           = viewModel.CategorizedEmployees;
            groupShortNameContainer.View.IsGroupingEnabled     = true;
            groupShortNameContainer.View.GroupShortNameBinding = new Binding("Key");

            // TODO - not sure how to do this
            var hasUnevenRowsContainer = new ViewContainer <ListView>(Test.ListView.HasUnevenRows, new ListView());

            InitializeElement(hasUnevenRowsContainer.View);
            hasUnevenRowsContainer.View.HasUnevenRows = true;
            hasUnevenRowsContainer.View.ItemTemplate  = new DataTemplate(typeof(UnevenCell));

            var isGroupingEnabledContainer = new StateViewContainer <ListView>(Test.ListView.IsGroupingEnabled, new ListView());

            InitializeElement(isGroupingEnabledContainer.View);
            isGroupingEnabledContainer.View.ItemsSource           = viewModel.CategorizedEmployees;
            isGroupingEnabledContainer.View.IsGroupingEnabled     = true;
            isGroupingEnabledContainer.StateChangeButton.Clicked += (sender, args) => isGroupingEnabledContainer.View.IsGroupingEnabled = !isGroupingEnabledContainer.View.IsGroupingEnabled;


            var itemAppearingContainer = new EventViewContainer <ListView>(Test.ListView.ItemAppearing, new ListView());

            InitializeElement(itemAppearingContainer.View);
            itemAppearingContainer.View.ItemAppearing += (sender, args) => itemAppearingContainer.EventFired();

            var itemDisappearingContainer = new EventViewContainer <ListView>(Test.ListView.ItemDisappearing, new ListView());

            InitializeElement(itemDisappearingContainer.View);
            itemDisappearingContainer.View.ItemDisappearing += (sender, args) => itemDisappearingContainer.EventFired();

            var itemSelectedContainer = new EventViewContainer <ListView>(Test.ListView.ItemSelected, new ListView());

            InitializeElement(itemSelectedContainer.View);
            itemSelectedContainer.View.ItemSelected += (sender, args) => itemSelectedContainer.EventFired();

            var itemTappedContainer = new EventViewContainer <ListView>(Test.ListView.ItemTapped, new ListView());

            InitializeElement(itemTappedContainer.View);
            itemTappedContainer.View.ItemTapped += (sender, args) => itemTappedContainer.EventFired();

            // TODO
            var rowHeightContainer = new ViewContainer <ListView>(Test.ListView.RowHeight, new ListView());

            InitializeElement(rowHeightContainer.View);

            var selectedItemContainer = new ViewContainer <ListView>(Test.ListView.SelectedItem, new ListView());

            InitializeElement(selectedItemContainer.View);
            selectedItemContainer.View.SelectedItem = viewModel.Employees[2];

            var fastScrollItemContainer = new ViewContainer <ListView>(Test.ListView.FastScroll, new ListView());

            InitializeElement(fastScrollItemContainer.View);
            fastScrollItemContainer.View.On <Android>().SetIsFastScrollEnabled(true);
            fastScrollItemContainer.View.ItemsSource = viewModel.CategorizedEmployees;

            var scrolledItemContainer = new ViewContainer <ListView>(Test.ListView.Scrolled, new ListView());

            InitializeElement(scrolledItemContainer.View);
            scrolledItemContainer.View.ItemsSource = viewModel.Employees;
            var scrollTitle = scrolledItemContainer.TitleLabel.Text;

            scrolledItemContainer.View.Scrolled += (sender, args) =>
            {
                scrolledItemContainer.TitleLabel.Text = $"{scrollTitle}; X={args.ScrollX};Y={args.ScrollY}";
            };

            var refreshControlColorContainer = new ViewContainer <ListView>(Test.ListView.RefreshControlColor, new ListView());

            InitializeElement(refreshControlColorContainer.View);
            refreshControlColorContainer.View.RefreshControlColor    = Color.Red;
            refreshControlColorContainer.View.IsPullToRefreshEnabled = true;
            refreshControlColorContainer.View.Refreshing            += async(object sender, EventArgs e) => {
                await Task.Delay(2000);

                refreshControlColorContainer.View.IsRefreshing = false;
            };
            refreshControlColorContainer.View.ItemsSource = viewModel.Employees;

            var scrollbarVisibilityContainer = new ViewContainer <ListView>(Test.ListView.ScrollBarVisibility, new ListView());

            InitializeElement(scrollbarVisibilityContainer.View);
            scrollbarVisibilityContainer.View.HorizontalScrollBarVisibility = ScrollBarVisibility.Never;
            scrollbarVisibilityContainer.View.VerticalScrollBarVisibility   = ScrollBarVisibility.Never;
            scrollbarVisibilityContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            scrollbarVisibilityContainer.View.IsGroupingEnabled   = true;
            scrollbarVisibilityContainer.View.GroupDisplayBinding = new Binding("Key");

            Add(groupDisplayBindingContainer);
            Add(groupHeaderTemplateContainer);
            Add(groupShortNameContainer);
            Add(hasUnevenRowsContainer);
            Add(isGroupingEnabledContainer);
            Add(itemAppearingContainer);
            Add(itemDisappearingContainer);
            Add(itemSelectedContainer);
            Add(itemTappedContainer);
            Add(rowHeightContainer);
            Add(selectedItemContainer);
            Add(fastScrollItemContainer);
            Add(scrolledItemContainer);
            Add(refreshControlColorContainer);
            Add(scrollbarVisibilityContainer);
        }
Beispiel #10
0
        protected virtual void Build(StackLayout stackLayout)
        {
            var isFocusedView = new T();

            isFocusedView.SetValueCore(IsFocusedPropertyKey, true);

            var viewContainers = new[] {
                _isFocusedStateViewContainer  = new StateViewContainer <T> (Test.VisualElement.IsFocused, isFocusedView),
                _backgroundColorViewContainer = new ViewContainer <T> (Test.VisualElement.BackgroundColor, new T {
                    BackgroundColor = Color.Blue
                }),
                _focusStateViewContainer             = new StateViewContainer <T> (Test.VisualElement.Focus, new T()),
                _gestureRecognizerEventViewContainer = new EventViewContainer <T> (Test.View.GestureRecognizers, new T()),
                _inputTransparentViewContainer       = new LayeredViewContainer <T> (Test.VisualElement.InputTransparent, new T {
                    InputTransparent = true
                }),
                IsEnabledStateViewContainer = new StateViewContainer <T> (Test.VisualElement.IsEnabled, new T {
                    IsEnabled = true
                }),
                _focusedEventViewContainer   = new EventViewContainer <T> (Test.VisualElement.Focused, new T()),
                _unfocusedEventViewContainer = new EventViewContainer <T> (Test.VisualElement.Unfocused, new T()),
                _isVisibleStateViewContainer = new StateViewContainer <T> (Test.VisualElement.IsVisible, new T {
                    IsVisible = true
                }),
                _opacityViewContainer = new ViewContainer <T> (Test.VisualElement.Opacity, new T {
                    Opacity = 0.5
                }),
                _rotationViewContainer = new ViewContainer <T> (Test.VisualElement.Rotation, new T {
                    Rotation = 10
                }),
                _rotationXViewContainer = new ViewContainer <T> (Test.VisualElement.RotationX, new T {
                    RotationX = 33
                }),
                _rotationYViewContainer = new ViewContainer <T> (Test.VisualElement.RotationY, new T {
                    RotationY = 10
                }),
                _scaleViewContainer = new ViewContainer <T> (Test.VisualElement.Scale, new T {
                    Scale = 0.5
                }),
                _translationXViewContainer = new ViewContainer <T> (Test.VisualElement.TranslationX, new T {
                    TranslationX = 30
                }),
                _translationYViewContainer = new ViewContainer <T> (Test.VisualElement.TranslationY, new T {
                    TranslationY = 30
                }),
            };

            // Set state
            IsEnabledStateViewContainer.StateChangeButton.Command = new Command(() => {
                IsEnabledStateViewContainer.View.IsEnabled = !IsEnabledStateViewContainer.View.IsEnabled;
            });
            _isVisibleStateViewContainer.StateChangeButton.Command = new Command(() => {
                _isVisibleStateViewContainer.View.IsVisible = !_isVisibleStateViewContainer.View.IsVisible;
            });

            _focusStateViewContainer.StateChangeButton.Command = new Command(() => {
                if (_focusStateViewContainer.View.IsFocused)
                {
                    _focusStateViewContainer.View.Unfocus();
                }
                else
                {
                    _focusStateViewContainer.View.Focus();
                }
            });

            _focusedEventViewContainer.View.Focused     += (sender, args) => _focusedEventViewContainer.EventFired();
            _unfocusedEventViewContainer.View.Unfocused += (sender, args) => _unfocusedEventViewContainer.EventFired();

            _gestureRecognizerEventViewContainer.View.GestureRecognizers.Add(
                new TapGestureRecognizer {
                Command = new Command(() => _gestureRecognizerEventViewContainer.EventFired())
            }
                );

            _views = new List <View> (viewContainers.Select(o => o.ContainerLayout));

            _moveNextStack = new StackLayout();
            var moveNextButton = new Button();

            moveNextButton.Text         = "Move Next";
            moveNextButton.AutomationId = "MoveNextButton";
            moveNextButton.Clicked     += delegate(object sender, EventArgs e) {
                if (!_views.Any())
                {
                    return;
                }

                if (_currentIndex + 1 >= _views.Count)
                {
                    return;
                }

                _currentIndex += 1;

                _moveNextStack.Children.RemoveAt(2);
                _moveNextStack.Children.Add(_views[_currentIndex]);
                _picker.SelectedIndexChanged -= PickerSelectedIndexChanged;
                _picker.SelectedIndex         = _currentIndex;
                _picker.SelectedIndexChanged += PickerSelectedIndexChanged;
            };

            _picker = new Picker();
            foreach (var container in viewContainers)
            {
                _picker.Items.Add(container.TitleLabel.Text);
            }

            _picker.SelectedIndex = _currentIndex;

            _picker.SelectedIndexChanged += PickerSelectedIndexChanged;

            _moveNextStack.Children.Add(_picker);
            _moveNextStack.Children.Add(moveNextButton);
            _moveNextStack.Children.Add(_views[_currentIndex]);

            stackLayout.Children.Add(_moveNextStack);

            if (!SupportsFocus)
            {
                stackLayout.Children.Remove(_focusStateViewContainer.ContainerLayout);
                stackLayout.Children.Remove(_isFocusedStateViewContainer.ContainerLayout);
            }

            if (!SupportsTapGestureRecognizer)
            {
                stackLayout.Children.Remove(_gestureRecognizerEventViewContainer.ContainerLayout);
            }

            foreach (var element in viewContainers)
            {
                InitializeElement(element.View);
            }
        }