Ejemplo n.º 1
0
        /// <summary>
        /// Called just before the view and its children are loaded.
        /// </summary>
        protected override void BeforeLoad()
        {
            if (IgnoreObject)
            {
                return;
            }
            base.BeforeLoad();

            bool autoSizeUndefined = AutoSizeProperty.IsUndefined(this);

            if (autoSizeUndefined)
            {
                // if autosize is undefined, set default value depending if width and height is set
                bool widthUndefined  = WidthProperty.IsUndefined(this);
                bool heightUndefined = HeightProperty.IsUndefined(this);

                if (widthUndefined && !heightUndefined)
                {
                    AutoSize = AutoSize.Width;
                }
                else if (!widthUndefined && heightUndefined)
                {
                    AutoSize = AutoSize.Height;
                }
                else if (widthUndefined && heightUndefined)
                {
                    AutoSize = AutoSize.WidthAndHeight;
                }
                else
                {
                    AutoSize = AutoSize.None;
                }
            }

            Label.AutoSize = AutoSize;
            if (AutoSize == AutoSize.None && WidthProperty.IsUndefined(this))
            {
                // if size isn't specified and the button doesn't adjust to label size, then set default width
                WidthProperty.SetValue(this, DefaultWidth, false);
            }

            if (LayoutParent is ToggleGroup)
            {
                // default to toggle-button if in toggle-group
                IsToggleButton = true;
                CanToggleOff   = false;
            }
        }
Ejemplo n.º 2
0
 set => SetValue(AutoSizeProperty, value);