templatebinding

In WPF, why does the Rectangle.Fill property not seem to work when using a TemplateBinding?

I can't figure out why this XAML code does not work. When using a TemplateBinding (see below), the background color is not set. But when I use a normal color string (i.e. "Red"), it works fine. <ControlTemplate x:Key="InstanceButtonTemplate" TargetType="{x:Type Control}"> <Grid> <Rectangle> <Rectangle.Fill> ...

TemplateBindings in Custom Controls

I'm just mucking about with custom controls in silverlight and for the life of me i can't get the TemplateBindings to work. Can someone give this reduced version a once over to see if I'm missing something. So my ControlTemplate in the generic.xaml looks like <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/pre...

The binding is getting lost on clicking second time on control

Hi, Please Refer to the following code.. Whenever a user clicks for the second time on the control, the text of the TextBox (in control template) becomes null.. Kindly proovide a solution.. Thanks in advance ...

WPF TemplateBinding vs RelativeSource TemplatedParent

What is the difference between <ControlTemplate TargetType="{x:Type Button}" x:Key="buttonTemplate"> <Border BorderBrush="{TemplateBinding Property=Background}" BorderThickness="3" > <ContentPresenter Margin="10"/> </Border> </ControlTemplate> and <ControlTemplate TargetType="{x:Type Button}" x:Key="buttonTemplate"> ...

TemplateBinding "Foreground" doesn't work

I have a listbox the item template of which is a listbox. I am trying to set the "Foreground" property of the internal listbox to be the same as that of the main listbox. This is failing. Following is the code snippet. In here Foreground="{TemplateBinding Foreground}" has no effect. <ListBox x:Name="GroupListBox" Grid.Column="1" Grid.Ro...

TemplateBinding not working with .NET framework objects...

Hi all, I am new to using the ControlTemplate. I am writing my first control but I am having (what seems to me) a very strange issue. Any dependency properties that I make that I TemplateBind to work, but any properties from the .NET framework objects i.e. the Content property of a ContentControl or the Items property of an ItemsContr...

Is It Possible to Use TemplateBinding in a Storyboard in Silverlight?

I'm building a custom control in Silverlight and I want one of the fields to animate to the value of a DependencyProperty when that property is changed. More specifically, I have particular item in my Control Template that I want to animate to the color of the Background whenever the background changes color. So, what I have is: <Contro...

How to TemplateBind to BorderThickness.Top (or Bottom or Left or Right)?

Hi friends. I wonder if it is possible to bind a structure element like BorderThickness.Top to TemplatedParent's corresponding property. I have tried <Border Margin="0" Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}"> <Border.BorderThickness> <Thickness Left="0" Right="0" Top="{TemplateBinding...

Binding to Transforms in a ControlTemplate

I'm trying to create a custom control in Silverlight that dynamically scales an element in it's ControlTemplate. First attempt of the ControlTemplate looks something like this: <ControlTemplate TargetType="controls:ProgressBar"> <Grid> <Rectangle x:Name="TrackPart" Fill="{TemplateBinding Background}" HorizontalAlignment="Left"...

WPF - styling a lookless control: How to access dependecy properties of control from second level of ControlTemplates?

Hello, I am extending the ItemsControl (class EnhancedItemsControl : ItemsControl), because I want to add several dependecy properties to it - like AlternativeContent which will be displayed when there are no items in collection (think of 'enter a search terms and hit search' label in a itemscontrol for results of search). I have subcla...

Using {TemplateBinding Content} withTextBlock in ControlTemplate

Basically I have a button that I built a control template for. It is currently working but VS 2010 complains about the following line of code in my control template <TextBlock Text="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" x:Name="cContentTextBlock" /> The control template is for a Button and I ...

Silverlight 3 ProgressBar Template

Hi All, I am trying to retemplate a Silverlight3 progress bar, to show the "Value" in a TextBlock within the ProgressBarIndicator, and the "Maximum" in another textblock in the ProgressBarTrack. I think that using TemplateBinding on the Value and Maximum properties would do this, but it isn't working. FYI the template I have so far i...

WPF ControlTemplate: How to provide a default value for TemplateBinding?

I am writing a WPF control that subclasses a Button. I then provide a default style in Themes\generic.xaml, that looks like this (simplified): <Style TargetType="{x:Type WPFControls:MyButton}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type WPFControls:MyButton}"> <Button x:Name="PART_B...

WPF ComboBox TemplateBinding to selected value

I'm trying to create an editable textbox via a drop down of selected values. Basically in Red Only mode I want the drop down to be a disabled textbox. It works fine when I do this with SelectedValue but when I need it to display the dropdown text and not the value. This is what I have: <Style x:Key="EditableDropDownValueOnly" TargetType...

TemplateBinding with Converter - what is wrong?

I'm creating a game desk. I wanted to specify field size (one field is a square) as a attached property and with this data set value of ViewPort which would draw 2x2 matrix (and tile mode would do the rest of game desk). I'm quite at loss what is wrong because the binding doesn't work. Testing line in XAML for the behaviour I would lik...

Cannot convert the value in attribute '[attr]' to object of type 'System.Windows.TemplateBindingExtension'.

Hi, I get this error when I define my attached dependency properties in a class outside the class hierarchy and set the owner to a common parent class. Attached dependency property in WindowBase class (outside class hierarchy => generated error): public static readonly DependencyProperty AreaColorProperty = DependencyProperty.Register...

Update source with TemplateBinding

I use this style for all my labels <Style TargetType="Label" x:Key="LabelStyle"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Label"> <StackPanel Orientation="Horizontal" > <TextBox Loaded="MyTextBlock_Loaded" x:Name="EditCon...

WPF DataTemplate property set at Content

New to WPF and have Tabs and in each tab the content is presented in a curved corner panel/window/whateveryouwannacallit. I wasn't sure how to do this ( Style, ControlTemplate ) but decided to go the DataTemplate way. So now I have this DataTemplate: <DataTemplate x:Key="TabContentPresenter" > <Border Margin="10" Border...