当前位置: 首页>>代码示例>>C#>>正文


C# ControlTemplate.Seal方法代码示例

本文整理汇总了C#中System.Windows.Controls.ControlTemplate.Seal方法的典型用法代码示例。如果您正苦于以下问题:C# ControlTemplate.Seal方法的具体用法?C# ControlTemplate.Seal怎么用?C# ControlTemplate.Seal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.ControlTemplate的用法示例。


在下文中一共展示了ControlTemplate.Seal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewElement

        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));
        }
开发者ID:hugodahl,项目名称:powershell-for-developers,代码行数:15,代码来源:ViewElement.cs

示例2: CreateDefaultErrorTemplate

        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;
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:21,代码来源:validation.cs

示例3: CreateDefaultControlTemplate

        // 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);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:89,代码来源:ScrollViewer.cs

示例4: AddIndicator

        // 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;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:33,代码来源:GridViewHeaderRowPresenter.cs

示例5: EditableContentControl

        /// <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);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:29,代码来源:EditableContentControl.cs

示例6: AddIndicator

        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;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:20,代码来源:TreeGridHeaderRowPresenter.cs


注:本文中的System.Windows.Controls.ControlTemplate.Seal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。