本文整理汇总了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);
}
示例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();
}
示例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;
}
示例4: SymbolControl
public SymbolControl(ControlTemplate template)
{
Template = template;
_dataContext = new SymbolControlContext();
DataContext = _dataContext;
HorizontalContentAlignment = HorizontalAlignment.Center;
}
示例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);
}
示例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]);
}
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}
示例11: CreateTemplate
private static ControlTemplate CreateTemplate()
{
ControlTemplate result = new ControlTemplate(typeof(UiImageButton));
FrameworkElementFactory contentPresenter = new FrameworkElementFactory(typeof(ContentPresenter));
result.VisualTree = contentPresenter;
return result;
}
示例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));
}
示例13: FormMain
public FormMain()
{
InitializeComponent();
menuTemplate = (ControlTemplate)FindResource("currencyMenu");
I = this;
CultureInfo.NumberFormat = (NumberFormatInfo)CultureInfo.NumberFormat.Clone();
CultureInfo.NumberFormat.CurrencySymbol = "";
Thread.CurrentThread.CurrentCulture = CultureInfo;
}
示例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] ";
}
示例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;
}