/// <summary>
        /// Updates layout.
        /// </summary>
        public override bool UpdateLayout(bool notifyParent = true)
        {
            bool hasNewSize = false;
            var  newWidth   = new ElementSize(HeaderGroup.ActualWidth, ElementSizeUnit.Pixels);

            if (!newWidth.Equals(Width))
            {
                WidthProperty.SetValue(this, newWidth, false);
                hasNewSize = true;
            }

            return(base.UpdateLayout(notifyParent) || hasNewSize);
        }
示例#2
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;
            }
        }