contentpresenter

Changing the Foreground colour of a contentpresenter in a listbox

I have created the following style for a listbox that will have an image displayed next to some text: <Style x:Key="ImageListBoxStyle" TargetType="{x:Type ListBox}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="ScrollViewer.HorizontalScrollBarVisibilit...

How do I get the instance of a templated item from a databound ItemsControl? (WPF)

I have an <ItemsControl> with a custom <DataTemplate> (and also a custom <ItemsPanelTemplate> that is just a WrapPanel), bound via ItemsSource to a simple observable collection of strings. The DataTemplate consists simply of an instance of a custom UserControl whose properties are bound to the string via {Binding}. The problem is since...

How can I make a Button with multiple content values?

My goal is to make a Button that has two Content values. Imagine a Scrabble tile as a button: it has the large letter in the center and a small number in the lower right. This is the effect I am going for. I made a button that has two ContentPresenter objects in it, and I have given each of the ContentPresenters a different style. ...

How do I completely replace the content of a WPF button with a graphic path?

I've deconstructed a standard WPF button using Blend and have managed to create a nicely styled button, but I cannot figure out how to make the path fill the interior of the button space (the button width and height). I am also not sure if I need to specify ContentPresenter or even if it is correct. I am after the text in the middle of t...

control to interchange UIElements in WPF

What is the most minimal way to dynamically interchange UIElements at a certian "slot" on the UI? I have a number of UIElements and based on some external databinding (e.g. a combobox selection) I want one of them to be shown and the one that was currently visible to be hidden. So the behavior is sort of like the tabcontrol but without t...

WPF: template or UserControl with 2 (or more!) ContentPresenters to present content in 'slots'

Hello, I am developing LOB application, where I will need multiple dialog windows (and displaying everything in one window is not an option/makes no sense). I would like to have a user control for my window that would define some styling, etc., and would have several slots where content could be inserted - for example, a modal dialog wi...

wpf ContentPresenter wont enable/disable

Hi, I've overridden a ComboBox in order to add an extra button at the end of the combo - i'm using this to help navigate round my application. Its a M-V-VM App that has an Edit-Save/Cancel mechanism that disables or enables the controls depending on whether or not the user is in 'edit mode'. I wanted my navigation button to always be...

WPF ContentPresenter bound to a collection

Hi I have a collection of string. I want to create an image out of each of the strings using a converter. I tried binding the collection to a ContentPresenter, but I don't know what do to when binding to a collection since I don't know how many items are in the collection. I don't want to put it in a container such as listbox, I want...

Is it possible to embed text formatting in a Silverlight ContentPresenter?

I have just started working with with Styles and Control Templates and have created the following styles to display a button as text in a grid. I would like to embed Font Styling into the styles for underlining but have not figured it out. <Style x:Key="TextButtonStyle" TargetType="Button"> <Setter Property="Background" Value="Li...

Does anyone have a simple example of a UserControl with a single ContentPresenter?

So far, I have this: <UserControl x:Class="MyConcept.ExpanderPanel" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <Grid> <Border Style="{StaticResource Border_PanelStyle}" CornerRadius="3" /> <ContentPre...

Silverlight: Can I create a custom button which contains two TextBlocks, each of which binds to a different property on an object?

I want to make buttons similar to those on this website. Lets say that the object I'm working with is ArtPiece, and has a Title and Date. I want both of those to show up on my buttons in two different TextBlocks. I've been trying to modify the button's ContentTemplate, then modifying the button's ContentPresenter inside the ContentTem...

WPF TabItem Style with image

I have a TabControl with TabItems, The Tab Items have text and an icon. To do this I have to add a StackPanel to the TabItem. However, once I add the StackPanel I can no longer control the default style of the text. Resource: <Style TargetType="{x:Type TabItem}"> <Setter Property="Template"> <Setter.Value> <Con...

How to customize and reuse a DataGridColumnHeader style?

Hi all, I'm trying to customize the column headers of a DataGrid to show sub-column headers as in the following screenshot: I've made a style for 2 sub-column as in the following XAML: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:data="clr...

Why do I get a NullReferenceException when using a style on a ContentPresenter?

I've created this template, which uses a style applied to the ContentPresenter so that I can bind the data object's Column property to Grid.Column, allowing the items to determine for themselves which column of the Grid they go into: <DataTemplate DataType="{x:Type local:MyObject}"> <ItemsControl ItemsSource="{Binding Items}"> <It...

WPF - DataTemplate to show only one hierarchical level in recursive data

Hi all, I am using a tree to display my data: persons grouped by their teams. In my model a team can contain another team, so the recursion. I want do display details about the selected node of the tree using a contentpresenter. If the selection is a person, everything is fine: I can show the person name or datails without problem using...

WPF Checkbox won't display a UIElement as its content.

I'm working with a custom checkbox, and I'm trying to set the content to a WPF Viewbox. The problem is, simply, nothing is displayed. The checkbox appears and works, but it has no content. This is sample code (not the actual code) of what I'm trying to do. MyCheckbox myCheckbox = new MyCheckbox(); Viewbox viewbox = new Viewbox(); viewb...

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}...

Convert ContentPresenter to TextBox in wpf

I have a test project which bases on : http://thejoyofcode.com/ViewModels_and_CheckListBoxes.aspx I want display field of object, not entire object. How to convert this <ContentPresenter Content="{Binding Value}" Margin="1"/> to this <TextBox Text="{Binding Path=Name}"></TextBox> and still have a object :) <Window x:Class="WpfA...

How can I set ContentPropertyAttribute to a Content Presenter?

I have a Usercontrol: SnazzyForm, which in addition to a couple of borders and and a header area and whatnot, also has a Content Presenter which under .NET Framework 3.5 presented content passed to it in other forms that used the control just fine. However after moving the project to 4.0 I am greeted with "Cannot add content to object o...

Underline the implicit Textblock created in Silverlight for a ContentPresenter when Content is a string?

I am trying to create a template for a content control such as Button or HeaderedContentControl etc. where the text is underlined. I just want to underline the text when Content="This text is underlined" is specified. It must continue to work as normal if Content is another UIElement. Most posts asking this same question are satisfie...