예제 #1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (BackgroundProperty.IsUnsetValue(this))
            {
                Background = GetBackgroundBrushFromTileColor(TileColor);
            }
        }
예제 #2
0
        /// <summary>
        /// Overriding to setup state.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (BackgroundProperty.IsUnsetValue(this))
            {
                Background = MetroTileFrame.GetBackgroundBrushFromTileColor(TileColor);
            }

            if (CommandParameterProperty.IsUnsetValue(this))
            {
                CommandParameter = this;
            }

            SetWidth(Type);

            var scaleTransform = GetTemplateChild("ScaleTransform") as ScaleTransform;

            if (scaleTransform != null)
            {
                scaleTransform.Bind(ScaleTransform.CenterXProperty, this, ActualWidthProperty, BindingMode.OneWay, _MultiplicationConverter, 0.5);
                scaleTransform.Bind(ScaleTransform.CenterYProperty, this, ActualHeightProperty, BindingMode.OneWay, _MultiplicationConverter, 0.5);
            }

            var content3d = GetTemplateChild("Content3D") as Content3D;

            if (content3d != null)
            {
                var transform = GetTemplateChild("RotateRightInwards") as RotateTransform3D;
                if (transform != null)
                {
                    transform.Bind(RotateTransform3D.CenterXProperty, content3d, Content3D.ThreeDBoundsXProperty);
                }
                transform = GetTemplateChild("RotateLeftInwards") as RotateTransform3D;
                if (transform != null)
                {
                    transform.Bind(RotateTransform3D.CenterXProperty, content3d, Content3D.ThreeDBoundsXProperty, BindingMode.OneWay, _MultiplicationConverter, -1);
                }
                transform = GetTemplateChild("RotateTopInwards") as RotateTransform3D;
                if (transform != null)
                {
                    transform.Bind(RotateTransform3D.CenterYProperty, content3d, Content3D.ThreeDBoundsYProperty);
                }
                transform = GetTemplateChild("RotateBottomInwards") as RotateTransform3D;
                if (transform != null)
                {
                    transform.Bind(RotateTransform3D.CenterYProperty, content3d, Content3D.ThreeDBoundsYProperty, BindingMode.OneWay, _MultiplicationConverter, -1);
                }
            }

            _FramesPresenter = GetTemplateChild("FramesPresenter") as MetroTileFramesPresenter;
            if (_FramesPresenter != null)
            {
                this.Bind(HasFramesProperty, _FramesPresenter, "HasItems");
            }
        }