• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Controls.ControlTemplate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ControlTemplate类属于System.Windows.Controls命名空间,在下文中一共展示了ControlTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MyThumb

 public MyThumb(ControlTemplate template, string title, Point position)
     : this()
 {
     this.Template = template;
     this.Title = (title != null) ? title : string.Empty;
     this.SetPosition(position);
 }
开发者ID:shader,项目名称:QuickArch,代码行数:7,代码来源:MyThumb.cs


示例2: OnTemplateChanged

 /// <summary>
 /// Provides derived classes an opportunity to handle changes to the Template property.
 /// </summary>
 protected virtual void OnTemplateChanged(ControlTemplate oldTemplate, ControlTemplate newTemplate)
 {
     _mask = (FrameworkElement)newTemplate.LoadContent();
     _canvas.Children.Clear();
     _canvas.Children.Add(_mask);
     SetBindings();
 }
开发者ID:modulexcite,项目名称:Glass-Legacy,代码行数:10,代码来源:RectangleSelectionAdorner.cs


示例3: Create

 internal static Adorner Create(UIElement element, ControlTemplate template)
 {
     var adorner = (Adorner)Constructor.Invoke(new object[] { element, template });
     adorner.Bind(FrameworkElement.DataContextProperty)
            .OneWayTo(element, FrameworkElement.DataContextProperty);
     return adorner;
 }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.Adorners,代码行数:7,代码来源:TemplatedAdorner.cs


示例4: SymbolControl

 public SymbolControl(ControlTemplate template)
 {
     Template = template;
     _dataContext = new SymbolControlContext();
     DataContext = _dataContext;
     HorizontalContentAlignment = HorizontalAlignment.Center;
 }
开发者ID:erindm,项目名称:route-planner-csharp,代码行数:7,代码来源:SymbolControl.cs


示例5: GetBuildDoneImage

        public static ControlTemplate GetBuildDoneImage(BuildInfo buildInfo, IEnumerable<ProjectItem> allProjects, out ControlTemplate stateImage)
        {
            if (buildInfo == null || buildInfo.BuildAction == null || buildInfo.BuildScope == null)
            {
                stateImage = null;
                return VectorResources.TryGet(BuildActionResourcesUri, "StandBy");
            }

            if (allProjects == null)
                throw new InvalidOperationException();

            int errorProjectsCount = allProjects.Count(item => item.State.IsErrorState());
            bool buildedProjectsSuccess = buildInfo.BuildedProjects.BuildWithoutErrors;

            string stateKey;
            if (buildInfo.BuildIsCancelled)
                stateKey = "BuildCancelled";
            else if (!buildedProjectsSuccess)
                stateKey = "BuildError";
            else if (buildedProjectsSuccess && errorProjectsCount == 0)
                stateKey = "BuildDone";
            else if (buildedProjectsSuccess && errorProjectsCount != 0)
                stateKey = "BuildErrorDone";
            else
                throw new InvalidOperationException();

            stateImage = VectorResources.TryGet(BuildStateResourcesUri, stateKey);

            string actionKey = GetBuildActionResourceKey(buildInfo.BuildAction.Value);
            return VectorResources.TryGet(BuildActionResourcesUri, actionKey);
        }
开发者ID:ashwinsathyar,项目名称:BuildVision,代码行数:31,代码来源:BuildImages.cs


示例6: ButtonBarControl

        public ButtonBarControl(WebcamControl element)
        {
            InitializeComponent();
            this.parent = element;
            this.Name = "buttonBar";
            int i;

            buttons=new Button[numberOfButtons];
            double buttonSpace = parent.WebcamImage.ActualWidth / numberOfButtons;

            Style style = new Style(typeof(Button));
            style.Setters.Add(new Setter { Property = OverridesDefaultStyleProperty, Value = true });

            Setter templateSetter = new Setter();
            templateSetter.Property = TemplateProperty;

            ControlTemplate controlTemplate = new ControlTemplate(typeof(Button));

            FrameworkElementFactory fact = new FrameworkElementFactory(typeof(Border));

            controlTemplate.VisualTree = fact;

            fact.Name = "Border";
            //fact.SetValue(Border.BorderThicknessProperty, new Thickness(1));
            //fact.SetValue(Border.CornerRadiusProperty, new CornerRadius(2));
            fact.SetValue(Border.BackgroundProperty,new TemplateBindingExtension(Button.BackgroundProperty));
            //fact.SetValue(Border.BorderBrushProperty, Brushes.Aquamarine);

            Trigger triggerIsMouseOver = new Trigger { Property = Border.IsMouseOverProperty, Value = true };

            Binding b = new Binding();
            b.RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent);
            b.Path = new PropertyPath(Button.BorderBrushProperty);

            Setter setter = new Setter(Border.BackgroundProperty, b, "Border");

            triggerIsMouseOver.Setters.Add(setter);

            controlTemplate.Triggers.Add(triggerIsMouseOver);
            templateSetter.Value = controlTemplate;

            style.Setters.Add(templateSetter);

            for (i = 0; i < numberOfButtons; i++)
            {
                buttons[i] = new Button();
                //buttons[i].Foreground = new ImageBrush(new BitmapImage(new Uri("test.png", UriKind.Relative)));
                buttons[i].Style = style;
                buttons[i].Background = new ImageBrush(new BitmapImage(new Uri((i+1)+"1.png", UriKind.Relative)));
                buttons[i].BorderBrush = new ImageBrush(new BitmapImage(new Uri((i+1)+"2.png", UriKind.Relative)));
                //buttons[i].Content = "Button" + i;
                buttons[i].Width = (buttonSpace-0.1*buttonSpace);
                buttons[i].Height = 100 - 20;
                buttons[i].Margin = new Thickness(0.05*buttonSpace, 10, 0.05*buttonSpace, 0);
                buttons[i].Click += new RoutedEventHandler(ButtonBar_Click);
                buttonStack.Children.Add(buttons[i]);

            }
        }
开发者ID:kovacshuni,项目名称:slrt,代码行数:59,代码来源:ButtonBarControl.xaml.cs


示例7: TemplatedAdorner

 /// <summary>
 /// Initializes a new instance of the <see cref="TemplatedAdorner"/> class.
 /// </summary>
 /// <param name="adornedElement">The adorned element.</param>
 /// <param name="dataContext">The data context.</param>
 /// <param name="adornerTemplate">The adorner template.</param>
 public TemplatedAdorner(UIElement adornedElement, object dataContext, ControlTemplate adornerTemplate)
     : base(adornedElement)
 {
     _child = new Control {Template = adornerTemplate};
     DataContext = dataContext;
     AddVisualChild(_child);
 }
开发者ID:PaulStovell,项目名称:bindable,代码行数:13,代码来源:TemplatedAdorner.cs


示例8: ComboBoxBackend

        //private static readonly DataTemplate DefaultTemplate;
        static ComboBoxBackend()
        {
            if (System.Windows.Application.Current.Resources.MergedDictionaries.Count == 0 ||
                !System.Windows.Application.Current.Resources.MergedDictionaries.Any(x => x.Contains(typeof(ExComboBox))))
            {
                var factory = new FrameworkElementFactory(typeof(WindowsSeparator));
                factory.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);

                var sepTemplate = new ControlTemplate(typeof(ComboBoxItem));
                sepTemplate.VisualTree = factory;

                DataTrigger trigger = new DataTrigger();
                trigger.Binding = new Binding(".[1]") { Converter = new TypeToStringConverter() };
                trigger.Value = typeof(ItemSeparator).Name;
                trigger.Setters.Add(new Setter(Control.TemplateProperty, sepTemplate));
                trigger.Setters.Add(new Setter(UIElement.IsEnabledProperty, false));

                ContainerStyle = new Style(typeof(ComboBoxItem));
                ContainerStyle.Triggers.Add(trigger);
            }
            else
            {
                ContainerStyle = null;
            }
        }
开发者ID:steffenWi,项目名称:xwt,代码行数:26,代码来源:ComboBoxBackend.cs


示例9: PinButton

 public PinButton(ControlTemplate template, string title, string imageSource, Point position)
     : this()
 {
     this.Template = template;
     this.ImageSource = (imageSource != null) ? imageSource : string.Empty;
     this.SetPosition(position);
 }
开发者ID:NamedJohnny,项目名称:Checkmapp-Windows-Phone-,代码行数:7,代码来源:PinButton.cs


示例10: MapDrawingExtensionMethods

 static MapDrawingExtensionMethods()
 {
     var sri = Application.GetResourceStream(new Uri("Vishcious.ArcGIS.SLContrib;component/resources/simplesymbols.xaml", UriKind.Relative));
     StreamReader sr = new StreamReader(sri.Stream);
     resources = XamlReader.Load(sr.ReadToEnd()) as ResourceDictionary;
     drawingPointTemplate = resources["SimpleMarkerSymbol_Circle"] as ControlTemplate;
     drawingLineTemplate = resources["LineSymbol"] as ControlTemplate;
     drawingPolygonTemplate = resources["FillSymbol"] as ControlTemplate;
 }
开发者ID:OliveiraThales,项目名称:GeoCache,代码行数:9,代码来源:MapDrawingExtensionMethods.cs


示例11: CreateTemplate

        private static ControlTemplate CreateTemplate()
        {
            ControlTemplate result = new ControlTemplate(typeof(UiImageButton));

            FrameworkElementFactory contentPresenter = new FrameworkElementFactory(typeof(ContentPresenter));

            result.VisualTree = contentPresenter;
            return result;
        }
开发者ID:akimoto-akira,项目名称:Pulse,代码行数:9,代码来源:UiImageButton.cs


示例12: MenuSeparatorStyleSelector

        static MenuSeparatorStyleSelector()
        {
            var rTemplate = new ControlTemplate(typeof(MenuItem));
            rTemplate.VisualTree = new FrameworkElementFactory(typeof(Separator));
            rTemplate.VisualTree.SetValue(Separator.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);

            r_SeparatorStyle = new Style(typeof(MenuItem));
            r_SeparatorStyle.Setters.Add(new Setter(MenuItem.TemplateProperty, rTemplate));
        }
开发者ID:XHidamariSketchX,项目名称:ProjectDentan,代码行数:9,代码来源:MenuSeparatorStyleSelector.cs


示例13: FormMain

        public FormMain()
        {
            InitializeComponent();
            menuTemplate = (ControlTemplate)FindResource("currencyMenu");

            I = this;
            CultureInfo.NumberFormat = (NumberFormatInfo)CultureInfo.NumberFormat.Clone();
            CultureInfo.NumberFormat.CurrencySymbol = "";
            Thread.CurrentThread.CurrentCulture = CultureInfo;
        }
开发者ID:ufasoft,项目名称:coin,代码行数:10,代码来源:f_main.xaml.cs


示例14: ControlTemplateElement

        /// <summary>
        /// Initializes a new instance of the <see cref="DataTemplateElement"/> class.
        /// </summary>
        /// <param name="controlTemplate">The data template.</param>
        /// <param name="boundType">Type of the bound.</param>
        /// <param name="baseName">Name of the base.</param>
        internal ControlTemplateElement(ControlTemplate controlTemplate, BoundType boundType, string baseName)
            : base(controlTemplate.LoadContent(), boundType)
        {
            _controlTemplate = controlTemplate;

            if(_controlTemplate.TargetType != null)
                BaseName = baseName + " [ControlTemplate " + _controlTemplate.TargetType.Name + "] ";

            else BaseName = baseName + " [ControlTemplate] ";
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:16,代码来源:ControlTemplateElement.cs


示例15: CreateTemplate

        private ControlTemplate CreateTemplate()
        {
            var template = new ControlTemplate();

            var label = new FrameworkElementFactory(typeof(Label));
            label.SetBinding(Label.ContentProperty, new Binding("Description"));
            template.VisualTree = label;

            return template;
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:10,代码来源:UIWithHierarchicalPath.cs


示例16: SymbolControl

        /// <summary>
        /// Instantiates new instance of <c>SymbolControl</c> class.
        /// </summary>
        /// <param name="template">Control template.</param>
        public SymbolControl(ControlTemplate template)
        {
            Template = template;

            _dataContext = new SymbologyContext();
            _dataContext.Attributes[SymbologyContext.SIZE_ATTRIBUTE_NAME] = SymbologyManager.DEFAULT_SIZE;
            _dataContext.Attributes[SymbologyContext.FULLSIZE_ATTRIBUTE_NAME] = SymbologyManager.DEFAULT_SIZE + SymbologyManager.DEFAULT_INDENT;
            DataContext = _dataContext;

            HorizontalContentAlignment = HorizontalAlignment.Center;
        }
开发者ID:erindm,项目名称:route-planner-csharp,代码行数:15,代码来源:SymbolControl.cs


示例17: ResizeThumb

        /// <summary>
        /// Initializes a new instance of the <see cref="ResizeThumb"/> class.
        /// </summary>
        /// <remarks>
        ///     Actually it will create a <see cref="Border"/> element and not <see cref="Thumb"/> element
        /// </remarks>
        public ResizeThumb()
            : base()
        {
            FrameworkElementFactory borderFactory = new FrameworkElementFactory(typeof(Border));
            borderFactory.SetValue(Border.BackgroundProperty, Brushes.Transparent);

            ControlTemplate template = new ControlTemplate(typeof(ResizeThumb));
            template.VisualTree = borderFactory;

            this.Template = template;
        }
开发者ID:jasper22,项目名称:RandomUI,代码行数:17,代码来源:WindowResizingAdorner.cs


示例18: setBackgroundImage

		public void setBackgroundImage(string normal_image_uri, string pressed_image_uri)
		{
			Style style = new Style();

			style.Setters.Add(new Setter(ForegroundProperty, MetrialColor.getBrush(MetrialColor.Name.White)));

			// Normal
			ControlTemplate normal_button_template = new ControlTemplate(typeof(Button));

			FrameworkElementFactory normal_button_shape = new FrameworkElementFactory(typeof(Rectangle));
			normal_button_shape.SetValue(Shape.FillProperty, makeImageBrush(normal_image_uri));
			//normal_button_shape.SetValue(Shape.StrokeProperty, Brushes.White);
			//normal_button_shape.SetValue(Shape.StrokeThicknessProperty, 2.0);

			FrameworkElementFactory normal_button_content_presenter = new FrameworkElementFactory(typeof(ContentPresenter));
			normal_button_content_presenter.SetValue(ContentProperty, new TemplateBindingExtension(ContentProperty));
			normal_button_content_presenter.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Center);
			normal_button_content_presenter.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center);

			FrameworkElementFactory normal_button_merged_element = new FrameworkElementFactory(typeof(Grid));
			normal_button_merged_element.AppendChild(normal_button_shape);
			normal_button_merged_element.AppendChild(normal_button_content_presenter);

			normal_button_template.VisualTree = normal_button_merged_element;
			style.Setters.Add(new Setter(TemplateProperty, normal_button_template));

			// For Pressed
			Trigger button_pressed_trigger = new Trigger();
			button_pressed_trigger.Property = Button.IsPressedProperty;
			button_pressed_trigger.Value = true;

			ControlTemplate pressed_button_template = new ControlTemplate(typeof(Button));

			FrameworkElementFactory pressed_button_shape = new FrameworkElementFactory(typeof(Rectangle));
			pressed_button_shape.SetValue(Shape.FillProperty, makeImageBrush(pressed_image_uri));
			//pressed_button_shape.SetValue(Shape.StrokeProperty, Brushes.White);
			//pressed_button_shape.SetValue(Shape.StrokeThicknessProperty, 2.0);

			FrameworkElementFactory pressed_button_button_content_presenter = new FrameworkElementFactory(typeof(ContentPresenter));
			pressed_button_button_content_presenter.SetValue(ContentProperty, new TemplateBindingExtension(ContentProperty));
			pressed_button_button_content_presenter.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Center);
			pressed_button_button_content_presenter.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center);

			FrameworkElementFactory pressed_button_mreged_element = new FrameworkElementFactory(typeof(Grid));
			pressed_button_mreged_element.AppendChild(pressed_button_shape);
			pressed_button_mreged_element.AppendChild(pressed_button_button_content_presenter);

			pressed_button_template.VisualTree = pressed_button_mreged_element;
			button_pressed_trigger.Setters.Add(new Setter(TemplateProperty, pressed_button_template));

			style.Triggers.Add(button_pressed_trigger);

			button.Style = style;
		}
开发者ID:jelee9,项目名称:wsr_pos_vs,代码行数:54,代码来源:RectButton.xaml.cs


示例19: Register

        public static void Register(ResourceDictionary resources)
        {
            var buttonTemplate = new FrameworkElementFactory(typeof(ButtonTemplate));

            var controlTemplate = new ControlTemplate(typeof(ToggleButton));
            controlTemplate.VisualTree = buttonTemplate;

            var style = new Style(typeof(ToggleButton));
            style.Setters.Add(new Setter(Control.TemplateProperty, controlTemplate));

            resources.Add(typeof(ToggleButton), style);
        }
开发者ID:kswoll,项目名称:restless,代码行数:12,代码来源:ToggleButtonStyle.cs


示例20: InitializeComponent

 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/MegaStarzWP7;component/Views/KaraokePage.xaml", System.UriKind.Relative));
     this.buttonTemplate = ((System.Windows.Controls.ControlTemplate)(this.FindName("buttonTemplate")));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.videoPlayer = ((System.Windows.Controls.MediaElement)(this.FindName("videoPlayer")));
     this.CameraPreview = ((System.Windows.Shapes.Rectangle)(this.FindName("CameraPreview")));
     this.button = ((System.Windows.Controls.Button)(this.FindName("button")));
 }
开发者ID:adirzim,项目名称:MegaStarz---WP7,代码行数:12,代码来源:KaraokePage.g.i.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.DataGrid类代码示例发布时间:2022-05-26
下一篇:
C# Controls.Control类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap