Esempio n. 1
0
 public ScrollViewerStyle(ScrollViewerStyle style) : base(style)
 {
     HorizontalScrollBackground = style.HorizontalScrollBackground;
     HorizontalScrollKnob       = style.HorizontalScrollKnob;
     VerticalScrollBackground   = style.VerticalScrollBackground;
     VerticalScrollKnob         = style.VerticalScrollKnob;
 }
Esempio n. 2
0
        public void ApplyScrollViewerStyle(ScrollViewerStyle style)
        {
            HorizontalScrollBackground = style.HorizontalScrollBackground;
            HorizontalScrollKnob       = style.HorizontalScrollKnob;
            VerticalScrollBackground   = style.VerticalScrollBackground;
            VerticalScrollKnob         = style.VerticalScrollKnob;

            ApplyWidgetStyle(style);
        }
Esempio n. 3
0
        private Style CreateScrollViewerStyle()
        {
            var style          = ScrollViewerStyle.CreateScrollViewerStyle();
            var templateSetter = style.Setters.FirstOrDefault(s => s.Property == Control.TemplateProperty);

            if (templateSetter != null)
            {
                var oldTemplate = templateSetter.Value as ControlTemplate;
                var funcType    = typeof(Func <UIElement, UIElement>);
                var funcField   = oldTemplate.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
                                  .FirstOrDefault(field => field.FieldType == funcType);
                var oldMethod = funcField?.GetValue(oldTemplate) as Func <UIElement, UIElement>;
                if (oldMethod != null)
                {
                    var newMethod = new Func <UIElement, UIElement>(parent =>
                    {
                        UIElement elem      = oldMethod(parent);
                        ScrollBar scrollBar = VisualTreeHelper.Instance.FindElementByName(elem, "PART_VerticalScrollBar") as ScrollBar;
                        if (scrollBar != null)
                        {
                            scrollBar.Width    = 12;
                            scrollBar.MaxWidth = 12;
                            scrollBar.MinWidth = 12;
                        }
                        scrollBar = VisualTreeHelper.Instance.FindElementByName(elem, "PART_HorizontalScrollBar") as ScrollBar;
                        if (scrollBar != null)
                        {
                            scrollBar.Height = 50;
                        }
                        return(elem);
                    });
                    funcField.SetValue(oldTemplate, newMethod);
                }
            }
            return(style);
        }