datatemplate

Focus DataTemplate in WPF

The behaviour I am looking for is that a selection of a Item in a ListView results in focusing the first focusable visualchild. Problem: datatemplated data in a ItemsControler which does not get an initial focus. In the example below there are 4 Strings which are then stuffed into a TextBox via Datatemplate. Example: <Window xmlns="ht...

WPF: Datatemplate For Class

I have this XAML: <UserControl x:Class="M_Cubed.Controls.TagEditor" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:classes="clr-namespace:M_Cubed.Classes"> <UserControl.Resources> <DataTemplate DataType="{x:Type classes:TagEditorPic}"...

only one usercontrol instance specified in datatemplate

I have specified a userControl as a dataTemplate. <TabControl IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=Pages}"> <TabControl.ContentTemplate> <DataTemplate> <uc:ItemTemplateControl /> </DataTemplate> </TabControl.ContentTemplate> </TabControl> The userControl is very easy and just binds...

WPF - Set DataTemplate for programmatically added GridViewColumns

Hi all, Couldn't find an answer to this one. I have a WPF ListView control that can contain varying number of columns. For example, it can display customer data, displaying columns Id, Name, Email etc, or it can contain products, displaying ID, Name, Price, NumberInStock, Manufacturer, well, you get the idea: varying number of columns,...

Draw custom element between listbox items

I want to draw custom elements (like an empty square> between the items of a listbox, to indicate that users can insert/drop items from another listbox between other items. How can I do this? I have some rather hacky solution for this, but I hope there is an easier way to do this. One of the ideas is to use different DataTemplates for ...

multiple userControl instances in tabControl

I have a tabControl that is bound to an observable collection. In the headerTemplate, I would like to bind to a string property, and in the contentTemplate I have placed a user-control. Here's the code for the MainWindow.xaml: <Grid> <Grid.Resources> <DataTemplate x:Key="contentTemplate"> <local...

Referencing controls in a WPF DataTemplate

In a WPF page that I'm designing for my church, I have two ListBox controls bound to the results of two Linq-to-Entities queries: the first listbox/query contains all the folks who haven't yet pledged for the year, the second listbox/query contains all the folks who have pledged (and their associated pledges). Specifically: var familie...

WPF ListBox - Getting UIElement instead of of SelectedItem

hi there, i created a ListBox that has a DataTemplate as Itemtemplate. however, is there an easy way to access the generated UIElement instead of SelectedItem in codebehind? when i access SelectedItem i just get the selected object from my ItemsSource collection. Is there a way to access the UIElement (ie. the element generated from th...

WPF Trigger for IsSelected in a DataTemplate for ListBox items with Blend

I wanted to change the Foreground color when I selected a listboxItem and I did it using this bit of code: <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True"> <Setter TargetName="descriptionTB" Property="Foregrou...

WPF DataTemplate Run function on button press?

Well the question says it all? I have a DataTemplate with a button is there any way to run a function or some how tell the object that the button was pressed? ...

Animate WPF Datatemplate when item added to Listbox?

Hello, In my project I have a WPF Listbox bound to an ObservableCollection. Every time I add a new item to the Collection the same item is added to the Listbox automaticly. To display the items in the Listbox I use a XAML Datatemplate. What I want to do is animate an item once when it is added to the Collection/Listbox. Can this be don...

dynamic datatemplate with valueconverter

I want to show data in a wpftoolkit datagrid where the data is a collection of public class Thing { public string Foo { get; set; } public string Bar { get; set; } public List<Candidate> Candidates { get; set; } } public class Candidate { public string Name { get; set; } public CandidateType CandidateType { get; se...

WPF - ItemTemplate not acting as expected.

I have a UserControl which I'm using to display a list of UIElements. The control consists of a single ItemsControl with it's ItemPanelTemplate switched for a horizontal StackPanel, its ItemsSource bound to a DependencyProperty exposed by the UserControl and its ItemTemplate set in the UserControl.Resources. Everything works fine exc...

WPF WrapPanel/StackPanel with DataTemplate?

Well the title says it all? what must i do to use a DataTemplate in a WrapPanel or StackPanel? On a ListBox its so easy but i cant find a way to do it on a Panel... Edit: What i want is a ListBox that places the items like a WrapPanel. ...

Getting a DynamicResource in code

hi there, the FrameworkElement's FindResource method allows to get resources defined in this frameworkelement. however, i have some dynamic resources located in another assembly loaded at runtime. Accessing it with DynamicResource from within XAML is no problem, but i wonder how i can get access to Dynamicresources from code (e.g. datat...

Is it possible to bind an Event in a Silverlight DataTemplate?

Is it possible to bind an Event in a Silverlight DataTemplate? If so, what is the best way to do it? For example, say you've created a DataTemplate that has a Button in it, like this: <UserControl.Resources> <DataTemplate x:Key="MyDataTemplate" > <Grid> <Button Content="{Binding ButtonText}" Margin="4" /> </Grid> ...

3d elements as items in a WPF ListBox

Hello, I'm wondering if anyone knows if it's possible in XAML to have a ListBox whose DataTemplate defines the ListBoxItem as a 3d element. Something along the lines of: <ListBox x:Name="lst3D" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <ListBox.ItemTemplate> <DataTem...

EventBinding in a codebehind generated DataTemplate

Hi there, lets begin with the scenario: I have an ItemsControl inside a UserControl. In this ItemsControl I have a dynamicly created DataTemplate which is created and added in codebehind. As there doesn't seem to be a nice way to create a DataTemplate in codebehind I had to programmatically generate the xaml code for my DataTemplate in...

How to use both a ControlTemplate and a DataTemplate to specify a TabItem

I need to use both a ControlTemplate and a DataTemplate at the same time - I think. I have a TabControl who's TabItems are supplied by an ObservableCollection - I can design the ObservableCollection items anyway that I choose. The TabItems need to use a ControlTemplate because they have a selected, not-selected, and disabled state so t...

Need help handling events of a DataTemplate in the Application.xaml file.

I have in my application a data template that has a few buttons. I want those buttons' even handler to be fired in the current page (I am using this template in many pages) rather than in the Application.xaml.vb/cs file, since I want different actions on each page. I hope I am clear. ...