controltemplate

WPF ControlTemplates must have TargetType or not?

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="{Templa...

GoToState not working on controltemplated usercontrol based on combobox

I'm trying to create a custom combobox that shows a loading animation when a bool property is set on it (e.g. IsLoading). I've created a control template in Blend based on the combobox, and added a textblock inside the togglebutton template. In the code behind I'm calling VisualStateManager.GoToState but it always returns false. I was t...

WPF GroupBox ControlTemplate : How to apply a Style only to elements in the Header ?

Hi. I'm trying to make a ControlTemplate for a GroupBox such as if a TextBlock is declared in the Header it's background should be set to yellow. The problem is that, although I define a style for TextBlocks in the ContentPresenter for the Header, it's not applied except on those TextBlocks which are autogenerated by WPF. Here is the...

wpf - why does this XAML override template not work

Any ideas regarding why the WPF XAML code I have is not working. I'm trying to override the WPFToolkit charting display, and have taken their default XAML and included in my Grid.Resources section as a means of overriding. Specifically I'm wanting to remove the graph markers, but this specific question pertains to clarifying my underst...

How to bind data to a ListBox in a ControlTemplate?

Hello Stackoverflow users, What I am trying to do is to create some sort of "rooms"(like a chat group, a sharing center or whatever you want). All the room are created the same way, but each one of them contains different informations. Each of these rooms is contained in a TabItem. I managed to create dynamically all the Tabitems, to gi...

Setting XAML attributes gets overwritten at runtime?

When I use the following line, implementing a templated control from a Silverlight class library; <labelSliderControl:SliderControl x:Name="sldX" Label="X" Value="4" /> I see in the VS Disign view the Slider getting the value of 4. But when I run the app the Slider starts at 0. So when I change the attribute in XAML I can see the c...

How to avoid waiting for Silverlight templated control initialisation in context of MVVM

I'm trying to make and use templated controls in an application but I seem to run into timing isssues. When I use a custom templated control, in XAML <local:MyControl> and through code (new MyControl()), and call a method on the control that tries to do something with a control in the Controltemplate, a control in the template is almost ...

Modify or 'tweak' an existing TreeViewItem control template - Take II

Ok, this is sort of a follow-up to my first question http://stackoverflow.com/questions/3827701/modify-or-tweak-an-existing-treeviewitem-control-template but since it is technically a new question, I'm told a good S/O visitor should create a new one, so here it is! Ok... the existing template for a TreeViewItem is based on a grid, a bor...

In a button's control template, how can I set the color of contained text?

Using Silverlight 4 & WPF 4, I'm trying to create a button style that alters the text color of any contained text when the button is mouseover'd. Since I'm trying to make this compatible with both Silverlight & WPF, I'm using the visual state manager: <Style TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> ...

WPF: Bind to command from ControlTemplate

Hi. I am trying to add a button to a custom ListView (MyListView) which triggers a command (MyCustomCommand) defined in MyListView. I have added the button (and a title text) by applying a ControlTemplate. The problem is that I have not found a way to trigger MyCustomCommand when clicking the button. What I eventually want to achieve is ...

How to get rid of the untouchable yellow border of the ribbon menu-button?

I'm new to WPF control template and need your help on this. I got a sample Microsoft Ribbon project here. I tried to change the color of the ribbon menu button but I can not make the yellow border goes off. Please see screenshot below. If you have a work-around, please help! You can get MS Ribbon from: http://www.microsoft.com/dow...

WPF - ListView Item on Selected change Font size

this is my code: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <ListBox ItemsSource="{Binding Persons}"> <ListBox.ItemContainerStyle> ...

WPF ComboBox: how to set focus on it's togglebutton

I'm trying to get a combobox to match a visual design, so its togglebutton has a blue border when the combobox has focus. I can't figure out how to do this and can't find an example. When the combobox gets focus, the textbox inside gets the dashed focus visual. How do I pass the combobox focus state down to the togglebutton, so that it'...

RenderingTemplate for ListForm Type

I created a custom RenderingTemplate "viewInventory" copy of ListForm rendering template. It looks like below. Then I associated the Rendering Template to a content type (this is list type content type) EditFormTemplateName. But it seems the list is not even using this controltemplate because I put a vogus name for editformtemplatename a...

"Object reference not set to an instance of an object." when setting a listview template.

I'm trying to switch between 2 templates on the basis of a data trigger. But I app crashes with the "Object reference not set to an instance of an object." If I comment out the setter for the template it runs fine. Here's my XAML: <Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}"> <Setter Property="Template" V...

WPF Changing text in a controltemplate at run time

I am making a template control so that I can have a button with an image that changes when you click it. I also am trying to get text on top of the button that can change at run time. I have the button images and everything working but I can't seem to get that label at runtime so I can change the text. Here is the code in the xaml. I...

WPF ScrollBar: both horizontal and vertical from one template?

I have a requirement to retemplate the Scrollbar so that only one template is required, instead of separate horizontal and vertical ones. The designer's assertion is that the scrollbar can be rotated on a trigger (Orientation = Horizontal), and the commands swapped on the buttons. Since the single template is set up as a grid with rows,...

Problems loading images in a Silverlight ControlTemplate

I have problems accessing images in the ControlTemplate of a "Silverlight Templated Control" I implemented. The Style for my control called "ControlDragger" is the following: <!-- ControlDragger Menu button style --> <Style x:Key="MenuButtonStyle" TargetType="Button"> <Setter Property="Margin" Value="5,0" /> <Setter Property="Te...