// Token: 0x06005984 RID: 22916 RVA: 0x0018B438 File Offset: 0x00189638
        private static ControlTemplate CreateDefaultErrorTemplate()
        {
            ControlTemplate         controlTemplate         = new ControlTemplate(typeof(Control));
            FrameworkElementFactory frameworkElementFactory = new FrameworkElementFactory(typeof(Border), "Border");

            frameworkElementFactory.SetValue(Border.BorderBrushProperty, Brushes.Red);
            frameworkElementFactory.SetValue(Border.BorderThicknessProperty, new Thickness(1.0));
            FrameworkElementFactory child = new FrameworkElementFactory(typeof(AdornedElementPlaceholder), "Placeholder");

            frameworkElementFactory.AppendChild(child);
            controlTemplate.VisualTree = frameworkElementFactory;
            controlTemplate.Seal();
            return(controlTemplate);
        }
        static ViewElement()
        {
            var self = typeof(ViewElement);

            var template = new ControlTemplate(self);

            var contentPresenter = new FrameworkElementFactory(typeof(ContentPresenter));
            contentPresenter.SetValue(ContentPresenter.ContentSourceProperty, "View");

            template.VisualTree = contentPresenter;

            template.Seal();

            TemplateProperty.OverrideMetadata(self, new FrameworkPropertyMetadata(template));
        }
Ejemplo n.º 3
0
        private static ControlTemplate CreateDefaultErrorTemplate()
        {
            ControlTemplate defaultTemplate = new ControlTemplate(typeof(Control));

            //<Border BorderThickness="1" BorderBrush="Red">
            //        <AdornedElementPlaceholder/>
            //</Border>

            FrameworkElementFactory border = new FrameworkElementFactory(typeof(Border), "Border");

            border.SetValue(Border.BorderBrushProperty, Brushes.Red);
            border.SetValue(Border.BorderThicknessProperty, new Thickness(1));

            FrameworkElementFactory adornedElementPlaceHolder = new FrameworkElementFactory(typeof(AdornedElementPlaceholder), "Placeholder");

            border.AppendChild(adornedElementPlaceHolder);

            defaultTemplate.VisualTree = border;
            defaultTemplate.Seal();

            return(defaultTemplate);
        }
Ejemplo n.º 4
0
        private static ControlTemplate CreateDefaultErrorTemplate()
        {
            ControlTemplate defaultTemplate = new ControlTemplate(typeof(Control));
 
            //<Border BorderThickness="1" BorderBrush="Red">
            //        <AdornedElementPlaceholder/> 
            //</Border> 

            FrameworkElementFactory border = new FrameworkElementFactory(typeof(Border), "Border"); 
            border.SetValue(Border.BorderBrushProperty, Brushes.Red);
            border.SetValue(Border.BorderThicknessProperty, new Thickness(1));

            FrameworkElementFactory adornedElementPlaceHolder = new FrameworkElementFactory(typeof(AdornedElementPlaceholder), "Placeholder"); 

            border.AppendChild(adornedElementPlaceHolder); 
 
            defaultTemplate.VisualTree = border;
            defaultTemplate.Seal(); 

            return defaultTemplate;
        }
Ejemplo n.º 5
0
        // Creates the default control template for ScrollViewer.
        private static ControlTemplate CreateDefaultControlTemplate()
        {
            ControlTemplate template = null;

            // Our default style is a 2x2 grid:
            // <Grid Columns="*,Auto" Rows="*,Auto">        // Grid
            //   <ColumnDefinition Width="*" />
            //   <ColumnDefinition Width="Auto" />
            //   <RowDefinition Height="*" />
            //   <RowDefinition Height="Auto" />
            //   <Border>                                   // Cell 1-2, 1-2
            //     <ScrollContentPresenter />
            //   </Border>
            //   <VerticalScrollBar  />                     // Cell 1, 2
            //   <HorizontalScrollBar />                    // Cell 2, 1
            // </Grid>
            FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid), "Grid");
            FrameworkElementFactory gridColumn1 = new FrameworkElementFactory(typeof(ColumnDefinition), "ColumnDefinitionOne");
            FrameworkElementFactory gridColumn2 = new FrameworkElementFactory(typeof(ColumnDefinition), "ColumnDefinitionTwo");
            FrameworkElementFactory gridRow1 = new FrameworkElementFactory(typeof(RowDefinition), "RowDefinitionOne");
            FrameworkElementFactory gridRow2 = new FrameworkElementFactory(typeof(RowDefinition), "RowDefinitionTwo");
            FrameworkElementFactory vsb = new FrameworkElementFactory(typeof(ScrollBar), VerticalScrollBarTemplateName);
            FrameworkElementFactory hsb = new FrameworkElementFactory(typeof(ScrollBar), HorizontalScrollBarTemplateName);
            FrameworkElementFactory content = new FrameworkElementFactory(typeof(ScrollContentPresenter), ScrollContentPresenterTemplateName);
            FrameworkElementFactory corner = new FrameworkElementFactory(typeof(Rectangle), "Corner");

            // Bind Actual HorizontalOffset to HorizontalScrollBar.Value
            // Bind Actual VerticalOffset to VerticalScrollbar.Value
            Binding bindingHorizontalOffset = new Binding("HorizontalOffset");
            bindingHorizontalOffset.Mode = BindingMode.OneWay;
            bindingHorizontalOffset.RelativeSource = RelativeSource.TemplatedParent;
            Binding bindingVerticalOffset = new Binding("VerticalOffset");
            bindingVerticalOffset.Mode = BindingMode.OneWay;
            bindingVerticalOffset.RelativeSource = RelativeSource.TemplatedParent;

            grid.SetValue(Grid.BackgroundProperty, new TemplateBindingExtension(BackgroundProperty));
            grid.AppendChild(gridColumn1);
            grid.AppendChild(gridColumn2);
            grid.AppendChild(gridRow1);
            grid.AppendChild(gridRow2);
            grid.AppendChild(corner);
            grid.AppendChild(content);
            grid.AppendChild(vsb);
            grid.AppendChild(hsb);

            gridColumn1.SetValue(ColumnDefinition.WidthProperty, new GridLength(1.0, GridUnitType.Star));
            gridColumn2.SetValue(ColumnDefinition.WidthProperty, new GridLength(1.0, GridUnitType.Auto));
            gridRow1.SetValue(RowDefinition.HeightProperty, new GridLength(1.0, GridUnitType.Star));
            gridRow2.SetValue(RowDefinition.HeightProperty, new GridLength(1.0, GridUnitType.Auto));

            content.SetValue(Grid.ColumnProperty, 0);
            content.SetValue(Grid.RowProperty, 0);
            content.SetValue(ContentPresenter.MarginProperty, new TemplateBindingExtension(PaddingProperty));
            content.SetValue(ContentProperty, new TemplateBindingExtension(ContentProperty));
            content.SetValue(ContentTemplateProperty, new TemplateBindingExtension(ContentTemplateProperty));
            content.SetValue(CanContentScrollProperty, new TemplateBindingExtension(CanContentScrollProperty));

            hsb.SetValue(ScrollBar.OrientationProperty, Orientation.Horizontal);
            hsb.SetValue(Grid.ColumnProperty, 0);
            hsb.SetValue(Grid.RowProperty, 1);
            hsb.SetValue(RangeBase.MinimumProperty, 0.0);
            hsb.SetValue(RangeBase.MaximumProperty, new TemplateBindingExtension(ScrollableWidthProperty));
            hsb.SetValue(ScrollBar.ViewportSizeProperty, new TemplateBindingExtension(ViewportWidthProperty));
            hsb.SetBinding(RangeBase.ValueProperty, bindingHorizontalOffset);
            hsb.SetValue(UIElement.VisibilityProperty, new TemplateBindingExtension(ComputedHorizontalScrollBarVisibilityProperty));
            hsb.SetValue(FrameworkElement.CursorProperty, Cursors.Arrow);
            hsb.SetValue(AutomationProperties.AutomationIdProperty, "HorizontalScrollBar");

            vsb.SetValue(Grid.ColumnProperty, 1);
            vsb.SetValue(Grid.RowProperty, 0);
            vsb.SetValue(RangeBase.MinimumProperty, 0.0);
            vsb.SetValue(RangeBase.MaximumProperty, new TemplateBindingExtension(ScrollableHeightProperty));
            vsb.SetValue(ScrollBar.ViewportSizeProperty, new TemplateBindingExtension(ViewportHeightProperty));
            vsb.SetBinding(RangeBase.ValueProperty, bindingVerticalOffset);
            vsb.SetValue(UIElement.VisibilityProperty, new TemplateBindingExtension(ComputedVerticalScrollBarVisibilityProperty));
            vsb.SetValue(FrameworkElement.CursorProperty, Cursors.Arrow);
            vsb.SetValue(AutomationProperties.AutomationIdProperty, "VerticalScrollBar");

            corner.SetValue(Grid.ColumnProperty, 1);
            corner.SetValue(Grid.RowProperty, 1);
            corner.SetResourceReference(Rectangle.FillProperty, SystemColors.ControlBrushKey);

            template = new ControlTemplate(typeof(ScrollViewer));
            template.VisualTree = grid;
            template.Seal();

            return (template);
        }
        // Create the indicator for column re-ordering
        private void AddIndicator()
        {
            Separator indicator = new Separator();
            indicator.Visibility = Visibility.Hidden;

            // Indicator style:
            //
            // <Setter Property="Margin" Value="0" />
            // <Setter Property="Width" Value="2" />
            // <Setter Property="Template">
            //   <Setter.Value>
            //     <ControlTemplate TargetType="{x:Type Separator}">
            //        <Border Background="#FF000080"/>
            //     </ControlTemplate>
            //   </Setter.Value>
            // </Setter>

            indicator.Margin = new Thickness(0);
            indicator.Width = 2.0;

            FrameworkElementFactory border = new FrameworkElementFactory(typeof(Border));
            border.SetValue(Border.BackgroundProperty, new SolidColorBrush(Color.FromUInt32(0xFF000080)));

            ControlTemplate template = new ControlTemplate(typeof(Separator));
            template.VisualTree = border;
            template.Seal();

            indicator.Template = template;

            InternalChildren.AddInternal(indicator);
            _indicator = indicator;
        }
        /// <summary>
        ///     This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.
        /// </summary>
        public EditableContentControl()
        {
            // create the EditModeTemplate definition; there is a limitation
            // that prevents doing this in xaml (child content cannot have the x:Name
            // property set for user controls that are partially defined using xaml)

            //<UserControl.Resources>
            //    <ControlTemplate x:Key="EditModeTemplate" 
            //                     TargetType="{x:Type UserControl}">
            //        <TextBox x:Name="textBox" 
            //                 Margin="0,0,0,0" 
            //                 LostKeyboardFocus="textBox_LostKeyboardFocus"
            //                 PreviewKeyDown="textBox_PreviewKeyDown">
            //        </TextBox>
            //    </ControlTemplate>
            //</UserControl.Resources>

            var factory = new FrameworkElementFactory(typeof(TextBox));
            factory.SetValue(NameProperty, textBoxName);
            factory.AddHandler(LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(textBox_LostKeyboardFocus));
            factory.AddHandler(PreviewKeyDownEvent, new KeyEventHandler(textBox_PreviewKeyDown));
            var editModeTemplate = new ControlTemplate(typeof(EditableContentControl));
            editModeTemplate.VisualTree = factory;
            editModeTemplate.Seal();
            Resources.Add(editModeTemplateKey, editModeTemplate);
        }
Ejemplo n.º 8
0
        private void AddIndicator()
        {
            var separator = new Separator();
            separator.Visibility = Visibility.Hidden;
            separator.Margin = new Thickness(0.0);
            separator.Width = 2.0;

            var frameworkElementFactory = new FrameworkElementFactory(typeof(Border));
            frameworkElementFactory.SetValue(Border.BackgroundProperty, new SolidColorBrush(Colors.Black));//Color.FromUInt32(4278190208u)

            var controlTemplate = new ControlTemplate(typeof(Separator));
            controlTemplate.VisualTree = frameworkElementFactory;
            controlTemplate.Seal();

            separator.Template = controlTemplate;

            base.UIChildren.Add(separator);

            this._indicator = separator;
        }