controltemplate

WPF - Apply a converter to all textboxes

Using WPF, I want to apply a converter within the binding of the Text property within all my TextBoxes. The following works for a single TextBox: <TextBox Style="{StaticResource TextBoxStyleBase2}" Text="{Binding Text, Converter={StaticResource MyConverter}}"> </TextBox> However, our T...

How do you make one line bold in a TreeView Class in WPF/C#?

How do you make one line bold in a TreeView Class in WPF/C#? I mean, how do you make just one line in a Tree View bold at runtime? ...

WPF ComboBox Binding breaks when using ControlTemplate

I have a WPF ComboBox that has been working fine until I recently created a ControlTemplate for it to enable me to change the color of the DropDown arrow. The ComboBox still works correctly except the Bound Text value now just shows the name of the Business Object rather than the bound value. I guess that binding like Text="{Binding P...

How do I bind a command to e.g. the right mouse button in a ControlTemplate in WPF?

I have a custom Control derived class and a view model to go with. The user can do several actions with this control, and I'm thinking it's best to implement these as RoutedCommand objects or ICommand derived objects in the view model so the ControlTemplates can bind to them. Binding a command to a button in one ControlTemplate should be...

DataContext as Source for Converter Binding Within Resources

<Canvas.DataContext> <ViewModels:VMSomeControl Model="{Binding RelativeSource={RelativeSource TemplatedParent}}" /> </Canvas.DataContext> <!-- DataContext is not passed into these Instances. they also have no knowledge of their TemplatedParent. --> <Canvas.Resources> <!-- is there a way to use a binding t...

Is it possible to dynamically change the style/template of a control?

I am creating a UserControl in Silverlight 4 which has a watermarked background. The watermark should change depending on the underlying 'type' the UserControl is representing. The watermark is created using a Path and I have extracted all the properties into a style. I was wondering if it would be possible to change the style of the ...

add button to tooltip template

Hi i want to add a close button on a validation tooltip, this is the current control template I have <ControlTemplate x:Key="ValidationToolTipTemplate"> <Grid x:Name="Root" Margin="5,0" RenderTransformOrigin="0,0" Opacity="0"> <Grid.RenderTransform> <TranslateTransform x:Name="xform" X="-25"/> ...

WPF: Binding to ObservableCollection in ControlTemplate is not updated

I created a ControlTemplate for my custom control MyControl. MyControl derives from System.Windows.Controls.Control and defines the following property public ObservableCollection<MyControl> Children{ get; protected set; }. To display the nested child controls I am using an ItemsControl (StackPanel) which is surrounded by a GroupBox. If...

Setter in property trigger fails if target property already has an explicit value

I'm currently trying to create a ControlTemplate for the Button class in WPF, replacing the usual visual tree with something that makes the button look similar to the little (X) close icon on Google Chrome's tabs. I decided to use a Path object in XAML to achieve the effect. Using a property trigger, the control responds to a change in t...

VS2010 cannot find type ControlTemplate even though System.Windows is referenced

I'm trying to learn Silverlight here, creating a custom control template, however VS2010 refuses to recognize the ControlTemplate type in markup code, even though I have referenced the System.Windows and System.Windows.Controls assemblies (which is by default when basing the project on the standard Silverlight Application template). I'm ...

DataTrigger inside ControlTemplate doesn't update

I have a ListBox that is bound to a list of CustomerViewModel-objects, that each has two dependency properties: - Name (string) - Description (string) - IsVisible (bool) (the IsVisible property is True by default and is reversed via the ToggleVisibility Command on the CustomerViewModel) I would like to display the Name and Descriptio...

ContentPresenter within ControlTemplate cannot change attached dependency property

Why does the following simplified code not sets the font-size of the TextBlock to 50? <Window.Resources> <ControlTemplate TargetType="ContentControl" x:Key="Test"> <ContentPresenter TextBlock.FontSize="50" /> </ControlTemplate> </Window.Resources> <Grid> <ContentControl Template="{StaticResource Test}...

Is it possible to include XAML ControlTemplates inside a ControlTemplate?

I'm working on an app that uses ControlTemplates to produce images dynamically. I need to create a unique XAML ControlTemplate that works as a css-sprite containing all other ControlTemplates XAML. Is it possible to include ControlTemplate XAML inside another ControlTemplate and keep the aggegated and individual files separated? ...

What's ControlTemplate TargetType attribute for in XAML? Can I avoid using it?

What's ControlTemplate TargetType attribute for? Can I avoid using it? ...

Is there a way to create a single css-sprite from multiple XAML ControlTemplates?

Is there a way to create a single css-sprite from multiple XAML ControlTemplates? I have several ControlTemplates and I want to combine all those images into a single XAML file and then create a single css-sprite. Thanks in advance. ...

Reference to control inside a ControlTemplate

How do I, form my contructor in the code-behind get a reference to the OuterBorder control in the XAML below? <Window Template="{DynamicResource WindowTemplate}"> <Window.Resources> <ControlTemplate x:Key="WindowTemplate" TargetType="{x:Type Window}"> <AdornerDecorator> <Border Name="OuterBo...

WPF custom validator with tooltip

Hi, I'd like to create a custom validator template for my WPF app. I have a tooltip template: <ControlTemplate x:Key="ToolTipTemplate" TargetType="ToolTip"> <Grid Opacity="0.93" MaxWidth="200"> <Border BorderBrush="Black" BorderThickness="1,1,1,1" CornerRadius="2"> <Border.Background> ...

Visual-state in SilverLight? (how we use that)

Hi I wrote simple template in xaml for button s.(for silver-light 4) So when I try use "ControlTemplate.Triggers", I found that is impossible in silver-light, and we must use Visual-State in Silver-Light so I wrote first ControlTemplate with Visual-State but it not work fine.(here is code) <Style x:Key="NextButtonStyle" TargetType="B...

Using a ControlTemplate to display a "browse" button beside a textbox used for filenames

Hi, I am attempting to attach a "Browse" button to a number of textboxes that will contain filenames. I was aiming for something like this: <TextBox Text="c:\Filename.txt" Template="{StaticResource FileBrowser}"/> The control template I declared is as follows: <Window.Resources> <ControlTemplate x:Key="FileBrowser" TargetType="...

Listbox styling and control template issue in silverlight...

Hi all, I have to change Listbox's control templated in a way that it can look like below image i have added togglebutton in listboxdatatemplate... have one stackpanel in listbox style template... so structure is like border - stackpanel - grid - itemcontainer[boder-togglerbutton] now to make first and last item curved... what are th...