Exemplo n.º 1
0
        /// <summary>
        /// The default template for the <see cref="ProgressBar"/> control.
        /// </summary>
        /// <param name="control">The control being styled.</param>
        /// <returns>The root of the instantiated template.</returns>
        public static Control Template(ProgressBar control)
        {
            Border container = new Border
            {
                [~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
                [~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
                [~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],

                Child = new Grid
                {
                    MinHeight = 14,
                    MinWidth = 200,

                    Children = new Controls
                    {
                        new Border
                        {
                            Name = "PART_Track",
                            BorderThickness = 1,
                            [~Border.BorderBrushProperty] = control[~TemplatedControl.BackgroundProperty],
                        },

                        new Border
                        {
                            Name = "PART_Indicator",
                            BorderThickness = 1,
                            HorizontalAlignment = HorizontalAlignment.Left,
                            [~Border.BackgroundProperty] = control[~TemplatedControl.ForegroundProperty],
                            Child = new Grid
                            {
                                Name = "Animation",
                                ClipToBounds = true,
                            }
                        }
                    }
                }
            };

            return container;
        }
Exemplo n.º 2
0
        public void Should_Return_FallbackValue_When_Invalid_Source_Type()
        {
            var target = new ProgressBar();
            var source = new Source { Foo = "foo" };
            var binding = new Binding
            {
                Source = source,
                Path = "Foo",
                FallbackValue = 42,
            };

            target.Bind(ProgressBar.ValueProperty, binding);

            Assert.Equal(42, target.Value);
        }