datatemplate

Binding Errors in DataTemplated ListBoxItems

Currently i have a user control which contains a listbox of other visual element user controls; which (for this special case) have been data templated. <Grid> <ListBox ItemSource="{Binding Path=UserControlCollection}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> ...

How do I track all instances of a DataTemplate, or a control within a DataTemplate?

I'm using a DataTemplate to apply a View to a ViewModel. I have a case where when a certain thing happens in one instance of the View (DataTemplate), I need to take an action in all other instances. I'm already accomplishing this by implementing the Initialized event on one of the controls in the DataTemplate, and using that event to a...

WPF updating UI when binding source changes

Hi guys. I have a WPF app with a listbox and a contentcontrol. The contentcontrol content is bound to the listbox and has a datatemplate that displays a textbox whose content is bound to a variable of the selected item in said listbox. So far, everything works well, i.e. when I select an item from the listbox the textbox content changes ...

WP7 ListBox Items to fill the width of the ListBox

Hi All, I am trying to get the Items in a ListBox to span the entire width of the ListBox. I have found several posts dealing with HorizontalContentAlignment="Stretch" but I have not been able to get it to work in my WP7 app. Here is my ListBox: <ListBox Margin="8" HorizontalContentAlignment="Stretch" ItemsSource="{Binding...

Access control binding information from GridViewColumn

I have code like this <GridViewColumn Header="Status" Width="75" DisplayMemberBinding="{Binding Path=TimesheetStatus}"/> <GridViewColumn Header="Reviewed?" Width="70"> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox Margin="1,2,1,0" IsEnabled="{Binding Path=EnableReview}" IsChecked="{Bi...

How do I display a collection of items with a template that uses a Grid in WPF?

I have a collection of objects that I would like to represent as a Grid with each object represented as a Rectangle (or a Button - haven't settled on this yet). Each object has an X and a Y property which represent its location in the Grid. For example, I might have four objects: var one = new MyClass(){X=0, Y=0} var two = new MyClass(...

WPF HierarchicalDataTemlate for TreeView, binding flat datatable

Hello guys, I've got a flat ADO.NET datatable that stores hierarchy. There is a data relation between fields ID and ParentID of the same table which describes hierarchy and there could be any number of levels. I want to show hierarchy in WPF TreeView. I know that I should make unnamed HierarchicalDataTemplate with DataType: markup ext...

Bind a Silverlight TabControl to a Collection

I have a Collection of Model-objects in my ViewModel. I would like to be able to bind a TabControl to these and use a DataTemplate to extract the information from the Model-objects. When I try to do this I get the errormessage: Unable to cast object of type Model to object of type TabItem. After spending some time looking for a solution ...

Animate ListBoxItem after pressing a button within DataTemplate

I have a ListBox with a DataTemplate for items. The DataTemplate contains a button. How do I rotate the UIElement represented by the DataTemplate when the button gets pressed? Any help greatly appreciated. ...

How do I apply a DataTemplate in a Dynamic Grid?

Hello, I have a Grid. The grid's columns are auto-generated at run-time based on the user's selection. I need the cells in the grid to be red if the content is a negative number. I have created a DataTemplateSelector. The DataTemplateSelector get's correctly called and returns my template if the cell is negative. Since my columns...

Silverlight template selector solution works great, but not blend able.

Before I begin here is a reference to how I implemented a template selector with Silverlight. http://geekswithblogs.net/tkokke/archive/2009/09/28/datatemplateselector-in-silverlight.aspx Everything works great. But the solution just doesn't work in blends making things more difficult to visualize overall. Is the correct work flow to ...

How to sort a Listview in a DataTemplate in XAML only?

I have a window with a TabControl that i've bind to a list of objec, I'll called MyItem : <TabControl Name="MyTabPNL" Background="Gainsboro" ItemsSource="{Binding MyItemList, ElementName=WatcherWindow}" ContentTemplate="{StaticResource tabItemTemplate}"> </TabControl> This MyItem class has an ObservableCollect...

Storyboard for a DataTemplate element in Silverlight

I have a DataGrid in my application, which have a column with defined CellTemplate with a text block and a button in it. I want to show the button only when hover this specific cell. How can i achieve this? Thanks in advance. ...

XAML tostring in ContentControl

I am new to the XAML world and I'm fumbling my way through a lot of tutorials. One thing i'm stuck on is calling the .tostring on an object. Here is mysetup I have a listbox that is bound to a list of objects I have a contentControl bound to the same list that displays the selected item from the listbox. My ContentControl is as follow...

add dyanmicly UIelement into stackpanel defined in dataTemplate

hello everybody, i m looking for to add dynamically a user interface element inside my stack panel here 's my code <DataTemplate x:Name="Mydt" > <Border Name="border" Padding="5" Margin="5"> <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> ...

How to display search results in a WPF items control with highlighted query terms

I'd like to display search results within a WPF ItemsControl with the query terms highlighted. The search engine I use, Lucene.Net with the Highlighter plugin, returns strings with the query terms marked up like so: ...these <Bold>results</Bold> were found to be statistically significant... I can instruct the Highlighter plugin to us...

Wpf DataTemplate

I have Defined a DataTemplate for ListView to Display the fileInfo details. This is the DataTemplate <DataTemplate x:Key="srchFileListTemplate"> <StackPanel> <WrapPanel> <TextBlock FontWeight="Bold" FontFamily="Century Gothic" Text="FileName :"/> <TextBlock Margin="10,0,0,0" FontWeigh...

Have a DataTemplate in XAML, need to programmaticaly set CellTemplate

I have DataTemplate, written in XAML <DataTemplate x:Key="AnalogTemplate" x:Name="AnalogTemplate" > <TextBox Text="{Binding parameter}" Background="Black"/> </DataTemplate> And I have some DataGrid How to apply DataTemplate "AnalogTemplate" to the one specified column in DataGrid programma...

ContextMenu on ListBox Item with DataTemplate

I have a ListBox with different classes of items. DataTemplates are used to present those objects in the appropriate way. I want to have different context menus in the DataTemplates of these classes. Everything works fine using the mouse, but using the keyboard I can't bring up the context menu. This is probably because the keyboard-fo...

WPF - DataTemplate - Using element binding within an attached property

I'm working on an application that uses a richly formatted ListBox. One of the things I need is to bind multiple pieces of information to a button that lives within the ListBox's DataTemplate. This is an over-simplification of my actual code that I made to help you understand the problem. Here's a chunk of XAML from inside the DataTem...