Exemplo n.º 1
0
        public override void OnApplyTemplate()
#endif
        {
            ApplyingTemplate();

            AppendCheck(Content);

            ButtonBaseHelper.ApplyForegroundToFillBinding(GetTemplateChild(ButtonBaseConstants.ContentBodyName) as ContentControl);
            ButtonBaseHelper.ApplyTitleOffset(GetTemplateChild(ButtonBaseConstants.ContentTitleName) as ContentControl);

            base.OnApplyTemplate();
        }
        private void IsEnabledStateChanged()
        {
            var contentBody    = GetTemplateChild(ButtonBaseConstants.ContentBodyName) as ContentControl;
            var enabledHolder  = GetTemplateChild(ButtonBaseConstants.EnabledHolderName) as Grid;
            var disabledHolder = GetTemplateChild(ButtonBaseConstants.DisabledHolderName) as Grid;

            if (contentBody != null && disabledHolder != null && enabledHolder != null)
            {
                if (!IsEnabled)
                {
                    enabledHolder.Children.Remove(contentBody);
                }
                else
                {
                    disabledHolder.Children.Remove(contentBody);
                }

                if (IsEnabled)
                {
                    if (!enabledHolder.Children.Contains(contentBody))
                    {
                        enabledHolder.Children.Insert(0, contentBody);
                    }
                }
                else
                {
                    if (!disabledHolder.Children.Contains(contentBody))
                    {
                        disabledHolder.Children.Insert(0, contentBody);
                    }
                }
            }

            UpdateLayout();

#if WINDOWS_STORE || WINDOWS_PHONE_APP
            if (ApplicationSpace.IsDesignMode)
            {
                ButtonBaseHelper.ApplyForegroundToFillBinding(contentBody);
            }
            else
            {
                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => ButtonBaseHelper.ApplyForegroundToFillBinding(contentBody)).AsTask();
            }
#elif WINDOWS_PHONE
            //Dispatcher.BeginInvoke(() =>
            ButtonBaseHelper.ApplyForegroundToFillBinding(contentBody);
            //);
#endif
        }
Exemplo n.º 3
0
        protected override void OnContentChanged(object oldContent, object newContent)
        {
            base.OnContentChanged(oldContent, newContent);

            if (oldContent == newContent)
            {
                return;
            }

            AppendCheck(Content);

            // content changed, wait a tick
#if WINDOWS_STORE || WINDOWS_PHONE_APP
            ButtonBaseHelper.ApplyForegroundToFillBinding(
                GetTemplateChild(ButtonBaseConstants.ContentBodyName) as ContentControl);
#elif WINDOWS_PHONE
            Dispatcher.BeginInvoke(() =>
                                   ButtonBaseHelper.ApplyForegroundToFillBinding(
                                       GetTemplateChild(ButtonBaseConstants.ContentBodyName) as ContentControl));
#endif
        }