controltemplate

WPF: Update a label in a listbox item.

I have a ListBox where the number of items is added based on and integer property set by a user. The items are created from a ControlTemplate resource that which is comprised of a Label and a TextBox inside of a DockPanel. The label is not data bound but I would like for it to have somewhat dynamic content based on the (index + 1) of the...

WPF Resource Dictionary in a separate assembly

I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in multiple separate applications. I could add them to the applications' assemblies, but it's better if I compile these resources in one single assembly and have my applications reference it, right? After the resource assembly is built, how...

How to place a ScrollViewer on top of the content it should scroll

I would like to put my ScrollViewer in such a way that it overlaps/sits on top of the content it scrolls. I would set the Opacity of the ScrollViewer so that the content is visible underneath. As far as I understand the default ScrollViewer, this doesn't seem to be possible out of the box since the content is nested inside the ScrollVie...

How to create a WPF Window without a border that can be resized via a grip only?

If you set ResizeMode="CanResizeWithGrip" on a WPF Window then a resize grip is shown in the lower right corner, as below: If you set WindowStyle="None" as well the title bar disappears but the grey bevelled edge remains until you set ResizeMode="NoResize". Unfortunately, with this combination of properties set, the resize grip also ...

WPF: Make Whole Border Clickable

I'm trying to implement a button in WPF which shows a menu when you click it. I've got everything working, and the ControlTemplate for the control is shown below. (The control extends ToggleButton). <Border x:Name="Border" Padding="3" CornerRadius="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsHi...

WPF Reusing a Template in other ControlTemplates

Hello, I am currently trying to figure out how to reuse a template in other controltemplates (as the title says). What I am trying to do is make a bunch of buttons that are all slightly different but have several similar features. They all share several of the same graphical elements and have the same triggers that deal with those graphi...

Silverlight 3: ListBox DataTemplate HorizontalAlignment

I have a ListBox with it's ItemTemplate bound to a DataTemplate. My problem is I cannot get the elements in the template to stretch to the full width of the ListBox. <ListBox x:Name="listPeople" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,0,0,0" Background="{x:Null}" SelectionMode="Extended" Grid.Row="1" ...

How to bind ControlTemplate Enabled property to Opacity in WPF XAML

In WPF inside XAML how to extend a ControlTemplate as such that when applied to a button and the button gets disabled it fades to 0.5 opacity while disabled and once enabled fades back to 1.0 opacity. This visual effect should work also when a parent is being disabled. ...

WPF: How to install thumb behavior in a Canvas?

I would like to have a Canvas that supports the DragDelta event. My first idea of how to do this was to make a ControlTemplate that includes a thumb. But I do not know how to do this correctly. How can I change the XAML below to make it compile, and what's the right way to install the DragDelta event handler? <UserControl.Resources> ...

WPF Border DesiredHeight

The following Microsoft example code contains the following: <Grid> ... <Border Name="Content" ... > ... </Border> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsExpanded" Value="True"> <Setter TargetName="ContentRow" Property="Height" Value="{Binding ElementName=Content,Path=DesiredHeight}" /> </T...

WPF: Button ControlTemplate + Spacebar = exception?

Hello, I've thrown together a template in Expression Blend for a button, and it works alright - until I tab over to it and press the spacebar. I get the following error: InvalidOperationException '[Unknown]' property does not point to a DependencyObject in path '(0).(1).[0].(2)'. The code is as follows: <ControlTemplate x:Key="E...

Do i have to build a ControlTemplate? Or is there an alternative?

I got a TreeView and want to display the Data nested (not hierarchically). The first level data is called TaskViewModel, the second level data is ArtifactViewModel. I want the ArtifactViewModel horizontal inside a GroupBox which represents TaskViewModel. I tried different approaches, this is my last one: <TreeView Name="tvTasks" ItemsSo...

WPF Creating a ControlTemplate that is DataBound

I have a control bound to an Object and all is well but I want to turn it into a control template bound to different objects of a similar type. I would like to do this exclusively in xaml, if possible. Any good tutorials that outline the steps? <TextBlock Text="{Binding Source={StaticResource BorderControl}, Path=ControlName}"/> EDI...

ReadOnlyCheckBox ControlTemplate

Hi, I've been trying to create my generic ReadOnlyCheckBox style/template but I'm having a problem with the binding to the data. In the example here: http://stackoverflow.com/questions/921921/a-read-only-checkbox-in-c-wpf you bind directly to the data from the ControlTemplate definition, but of course this is not really what I want, a...

Binding custom dependency property to custom WPF style

I have an issue when designing a inherited Expander. My intention is to have a progress bar behind the toggle button and text in the default Expander header. I have this XAML code which gives me the progress bar in the header. It is a custom style. <Style x:Key="CurrentScanExpanderStyle" TargetType="{x:Type local:ProgressExpander}"> ...

WPF: How to make a "pushlike" checkbox?

I would like to make a CheckBox that looks exactly like a button. My initial feeble attempt doesn't work at all. <CheckBox x:Name="test"> Testing! <CheckBox.Template> <ControlTemplate> <Button> <ContentPresenter/> </Button> </ControlTemplate> </CheckBox.Template> </Chec...

Passing parameters to a template

Hi, Say I have defined a button with rounded corners. <Style x:Key="RoundButton" TargetType="Button"> <!-- bla bla --> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border CornerRadius="0,5,5,0" /> <!-- bla bla --> </ControlTemplate> </Setter.Value> </Setter> </Style> I it pos...

how can we control the storyboard of the control template stored in app.xaml of label with the button which is in another xaml

Hello, I have prepared a control template for the label and stored in App.xaml because these control template is used by many labels in the xaml. Inside it i have a placed a storyboard in order to blink the label constantly. Here is the code for the same in App.xaml <ControlTemplate x:Key="LabelControlTemplate1" TargetType="{x:Type ...

Restyling just part of a wpf control. Is it possible?

I want to restyle just part of a WPF control. (Specifically, I want to make the scroll buttons on a ScrollBar bigger) Now I can do this no problem. I extracted the default style. Made the required tweaks and included the modified style in my application. The problem is that I have to include the entire control template in the replacem...

Adding a custom dependency property to a Control Template in XAML

Hi all, I have managed to get further with my read only check box after a bit of a break and now have the functionality I want in a reasonably elegant form. The problem is I have used a bit of a hack to make it work, although this is not a disaster it would be nice to do it better. To recap: I want a regular looking checkbox that does ...