internal static void SetScale(FrameworkElement element, SmartScaler smartscaler)
 {
     if (element is RadioButton || element is CheckBox)
     {
         smartscaler.SmartScaleFactor = 0.80;
     }
     else if (element is Panel panel)
     {
         if (panel.Children.Count > 0)
         {
             SetScale(panel.Children[0] as FrameworkElement, smartscaler);
         }
     }
 }
예제 #2
0
        protected override void OnApplyTemplate()
        {
            if (_init == true)
            {
                throw new System.Exception("can not re-template");
            }

            // Save existing content and remove it from the visual tree.
            // This is needed as the Child property is already set before the template XAML is loaded.
            FrameworkElement savedContent = this.Child;

            this.Child = null;

            base.OnApplyTemplate();

            _rootgrid      = this.GetTemplateChild("RootGrid") as Grid;
            _smartscaler   = this.GetTemplateChild("smartscaler") as SmartScaler;
            _header        = this.GetTemplateChild("textblockHeader") as TextBlock;
            _bottomremark  = this.GetTemplateChild("BottomRemark") as TextBlock;
            _rightremark   = this.GetTemplateChild("RightRemark") as TextBlock;
            _formbuttonbar = this.GetTemplateChild("FormButtonBar") as FormButtonBar;

            AutoStyler.SetStyle(savedContent);
            AutoStyler.SetMargin(savedContent);
            AutoStyler.SetScale(savedContent, _smartscaler);

            // Hook up the formbuttons collection to the FormButtonBar.
            _formbuttonbar.ItemsSource = this.Buttons;

            _init = true;

            ResetRemark();

            // Restore saved content
            this.Child = savedContent;

            this.PointerPressed += FormField_PointerPressed;
        }