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


C# Controls.ControlTemplate类代码示例

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


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


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