controltemplate

The ControlTemplate is causing the following error “The property 'Content' is set more than once”

好久不见. 提交于 2020-01-16 03:53:08
问题 I'm just trying for the first time to use a ControlTemplate for a button that I want to create. However, as soon as I put the tag <ControlTemplate> anywhere, it is coming up with an error. <Window x:Class="MAQButtonTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="695" Width="996"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="300" /> <ColumnDefinition /> </Grid

How to bind WPF Effect Color to Foreground or Background of ControlTemplate

谁说胖子不能爱 提交于 2020-01-14 10:16:48
问题 I am seeing some odd behaviour when it comes to Binding to the Color property of an Effect within a ControlTemplate. When setting the value directly, I can define the color as a string (eg. "Red") or as a Hex value (eg. #FFFF0000). However, when using binding, it ONLY works if the color is defined as a String, which is an issue in a ControlTemplate style, as I would like to use the colors of the TemplateParent properties, which get bound to as Hex values. For example. Take a look at the

WPF ControlTemplates must have TargetType or not?

烂漫一生 提交于 2020-01-11 04:42:07
问题 Do ControlTemplates in WPF require a TargetType? I am restyling some controls, and notice that the comboboxitem, listiviewitem and listboxitem all have the same template: <ControlTemplate x:Key="ListBoxItemCT" TargetType="{x:Type ListBoxItem}"> <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" CornerRadius="1">

how to change button template dynamically WPF

*爱你&永不变心* 提交于 2020-01-11 04:20:08
问题 How can I change a Button template dynamically? I have a ComboBox where by changing his selected value I want to change a Button Template . This is what I have been trying to do: <Window.Resources> <ControlTemplate x:Key="ButtonControlTemplate1" TargetType="{x:Type Button}"> <Grid> <Rectangle Fill="#FF2D2D7A" Margin="7.5,9.5,8.5,11" Stroke="Black" RadiusX="45" RadiusY="45" StrokeThickness="6"/> </Grid> </ControlTemplate> <ControlTemplate x:Key="ButtonControlTemplate2" TargetType="{x:Type

Put a “column header” over the ScrollViewer of a WPF ComboBox ControlTemplate

拜拜、爱过 提交于 2020-01-06 12:29:25
问题 here is my sample project updated from this thread: WPF: Refine the look of a grouped ComboBox vs. a grouped DataGrid -sample attached - http://www.sendspace.com/file/ru8hju (VS2010 .Net 4.0 project) My question is now HOW can I add a "column header" like stackpanel horizontal with 2 TextBlocks ADD to my existing ComboBox ControlTemplate ABOVE the ScrollViewer when I have a custom ComboBoxItem stuff and there is the ItemPresenter in the default ComboBox ControlTemplate. Thats my existing

How do I replace a ControlTemplate part at runtime, in Silverlight 3?

╄→гoц情女王★ 提交于 2020-01-06 01:52:07
问题 I'm writing a custom control which uses a template defined in the resources section of my XAML and I'd like to replace one or more template parts in an instance of my control at runtime. For example, if I have a part named "ActivePart" in the control's template, how do I replace the ActivePart's FrameworkElement in an instance of the control with a new FrameworkElement? I realise the Control.Template property is writeable, but I'd prefer to find a way to replace a specific part of that

How to use TwoWay binding from within a UserControl?

扶醉桌前 提交于 2020-01-03 09:44:09
问题 I have my own UserControl, a LabeledTextBox which is the combination of a Label and a..well, TextBox . This Control has two properties: Caption which will be bound to the caption of the Label , and Value which will be bound to the Text of the TextBox . Code: public class LabeledTextBox : Control { static LabeledTextBox() { DefaultStyleKeyProperty.OverrideMetadata(typeof(LabeledTextBox), new FrameworkPropertyMetadata(typeof(LabeledTextBox))); } public string Caption { get { return (string

Datagrid template with rounded corners

纵饮孤独 提交于 2020-01-02 10:02:25
问题 I'm creating DataGrid template with rounded corners, but I faced with this problem: Bottom corners are out of the border bounds. How to solve this? I've read this article: http://diptimayapatra.wordpress.com/2010/06/28/rounded-corner-datagrid-in-wpf/ I need to do the same, but in Template. Here is my DataGrid Template Code: <Style TargetType="{x:Type DataGrid}"> <Setter Property="Background" Value="{StaticResource ControlContentBrush}"/> <Setter Property="RowDetailsVisibilityMode" Value=

Datagrid template with rounded corners

陌路散爱 提交于 2020-01-02 10:00:13
问题 I'm creating DataGrid template with rounded corners, but I faced with this problem: Bottom corners are out of the border bounds. How to solve this? I've read this article: http://diptimayapatra.wordpress.com/2010/06/28/rounded-corner-datagrid-in-wpf/ I need to do the same, but in Template. Here is my DataGrid Template Code: <Style TargetType="{x:Type DataGrid}"> <Setter Property="Background" Value="{StaticResource ControlContentBrush}"/> <Setter Property="RowDetailsVisibilityMode" Value=

UserControl within a ControlTemplate

时光总嘲笑我的痴心妄想 提交于 2020-01-02 06:46:29
问题 I have a ControlTemplate for a Telerik Tile and I am overriding like below: <ControlTemplate TargetType="{x:Type ctrl:Tile}"> <Border> <local:UserControl> <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/> </local:UserControl> </Border> </ControlTemplate> My user control looks like: <DockPanel> <!-- some content --> <ContentPresenter/> </DockPanel> The ControlTemplate does not display the content of the UserControl. If I change my