wpf-datatemplate

WPF - Refresh contents of a DataTemplate

I have a tab that has its content set to an object (a TFS WorkItem). I have a DataTemplate for the WorkItem type. When I set the object to the tab it displays nicely. However, when I update one of the collections on the object (the list of links) this change is not refreshed to the view. I have tried making my WorkItem a DependencyPr...

WPF - Get DataTemplate without an event

I have a WPF Data template defined in my Windows.Resources section. I would like to access this (really a list box on it) via the code behind. How can I do this? I can't get what I want via an event because I want to get the reference in the completed step of a BackGroundWorker. (Ie no sender (that is a UI element) to go off of there...

WPF DataTemplate - x:Key vs DataType="{x:Type XXXX")

I have a DataTemplate that I want to find using the FrameworkElement.FindResource(). To do that I need to have a key on the data template. The problem is that x:key and assigning a data type are mutually exclusive. (Reference) So, once I set the DataType for my template, how do I find the Key value? Is there some formula that conver...

Apply DataTemplate to type derived from FrameworkElement

I've got a list of custom "pages" in my app. Each page represents a different UI view. They have some simple properties, like a string title and an icon, but they also have a number of complex properties, consisting of controls to insert into the main toolbar, a main content area, custom statusbar panels, etc. The page type derives from ...

Get the UI object from a data object

I have a class (MockWI) that I have defined the following DataTemplate in app.xml <DataTemplate DataType="{x:Type local:MockWI}"> <Button Content="{Binding Name}"/> </DataTemplate> In my code I need to find the UI object that an instance of MockWI has. Right now I do this: Button elt = new Button { Content = myMockWI}; But tha...

WPF - Create a UI object from a DataTemplate

This is very similar to this question I asked earlier. I am hoping to be clearer and get a different answser. I have a Data Object (called MockUI). It has a data template (in app.xaml) like this: <DataTemplate DataType="{x:Type local:MockWI}"> <Button Content="{Binding Name}"/> </DataTemplate> In my code I want create a UI obje...

Use a user control as a dataTemplate within a WPF application

Hello, I am trying to create a user control within a WPF application that will serve as a data template for a listbox item. The user control a grid with 4 textblocks. This control also contains other shapes and images more for visual aid than anything so I am omitting them from the code in this question for clarity. When I drop the use...

Triggers on a DataTemplate when data is updated

I've got a data template for a list box item similar to the one on this page... link I would like to take it a step further and do something to highlight the items when they change. For example, using the code in the link above, I would like to put a trigger to do something when Widget.Quantity changes. Maybe make the quiantity item (no...

WPF: Locate Parent Window from ListView ViewBase

I have a ListView that allows the user to change the ViewBase through a Context Menu (it acts like a simplified version of windows explorer). <ListView Name="lv" Grid.Row ="0" Grid.Column ="1" > <ListView.ContextMenu> <ContextMenu> <MenuItem Header="View1" Click="SwitchViewMenu"/> <M...

WPF auto-scrolling to items in a ListBox

When one presses a letter (or a sequence of letters) in a windows combobox or in a list, automatically the first item that starts with the given letter, is selected. Is there a declarative way to do the same thing for a WPF ListBox that has it's items bound by the ItemsSource-property and the ItemsTemplate set to a DataTemplate. ...