コード例 #1
0
 private void InitializeComponent()
 {
     PerspexXamlLoader.Load(this);
     _carousel = this.FindControl<Carousel>("carousel");
     _left = this.FindControl<Button>("left");
     _right = this.FindControl<Button>("right");
     _transition = this.FindControl<DropDown>("transition");
 }
コード例 #2
0
ファイル: DropDownTests.cs プロジェクト: MarkWalls/Perspex
        public void Logical_Children_Should_Be_Children_Of_Container()
        {
            var target = new DropDown();

            target.Template = this.GetTemplate();
            target.ApplyTemplate();

            var childIds = ((ILogical)target).LogicalChildren.Cast<Control>().Select(x => x.Name);

            Assert.Equal(new[] { "contentControl", "toggle", "popup" }, childIds);
        }
コード例 #3
0
ファイル: DropDownStyle.cs プロジェクト: healtech/Perspex
        /// <summary>
        /// The default template for a <see cref="DropDown"/> control.
        /// </summary>
        /// <param name="control">The control being styled.</param>
        /// <returns>The root of the instantiated template.</returns>
        public static Control Template(DropDown control)
        {
            Border result = new Border
            {
                [~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
                [~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
                [~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
                Child = new Grid
                {
                    Name = "container",
                    ColumnDefinitions = new ColumnDefinitions
                    {
                        new ColumnDefinition(new GridLength(1, GridUnitType.Star)),
                        new ColumnDefinition(GridLength.Auto),
                    },
                    Children = new Controls
                    {
                        new ContentControl
                        {
                            Name = "contentControl",
                            Margin = new Thickness(3),
                            [~ContentControl.ContentProperty] = control[~DropDown.SelectionBoxItemProperty],
                            [~Layoutable.HorizontalAlignmentProperty] = control[~DropDown.HorizontalContentAlignmentProperty],
                            [~Layoutable.VerticalAlignmentProperty] = control[~DropDown.VerticalContentAlignmentProperty],
                        },
                        new ToggleButton
                        {
                            Name = "toggle",
                            BorderThickness = 0,
                            Background = Brushes.Transparent,
                            ClickMode = ClickMode.Press,
                            Focusable = false,
                            Content = new Path
                            {
                                Name = "checkMark",
                                Fill = Brushes.Black,
                                Width = 8,
                                Height = 4,
                                Stretch = Stretch.Uniform,
                                HorizontalAlignment = HorizontalAlignment.Center,
                                VerticalAlignment = VerticalAlignment.Center,
                                Data = StreamGeometry.Parse("F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z"),
                                [Grid.ColumnProperty] = 0,
                            },
                            [~~ToggleButton.IsCheckedProperty] = control[~~DropDown.IsDropDownOpenProperty],
                            [Grid.ColumnProperty] = 1,
                        },
                        new Popup
                        {
                            Name = "popup",
                            Child = new Border
                            {
                                BorderBrush = Brushes.Black,
                                BorderThickness = 1,
                                Padding = new Thickness(4),
                                Child = new ItemsPresenter
                                {
                                    [~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
                                }
                            },
                            PlacementTarget = control,
                            StaysOpen = false,
                            [~~Popup.IsOpenProperty] = control[~~DropDown.IsDropDownOpenProperty],
                            [~Layoutable.MinWidthProperty] = control[~Visual.BoundsProperty].Cast<Rect>().Select(x => (object)x.Width),
                        }
                    },
                },
            };

            return result;
        }