datatemplate

How to build a generic/re-usable modal dialog for WPF following MVVM

I would like to build a generic/re-usable modal dialog that I can use in our WPF (MVVM) - WCF LOB application. I have a Views and associated ViewModels that I would like to display using dialogs. Bindings between Views and ViewModels are done using Type-targeted DataTemplates. Here are some requirements that I have been able to draft: ...

WPF DataTemplate Event binding to object function.

Hello, I'm currently writing DataTemplate for my custom type lets say FootballPlayer. In this template I would like to put ie. Button and make that button when clicked call some of FootballPlayer functions eg. Run(). Is there any simple or complex, but clean way to achieve this kind of behaviour? The DataTemplate I believe is aware of...

Binding WPF menu items to WPF Tab Control Items collection

I have a WPF Menu and a Tab control. I would like the list of menu items to be generated from the collection of TabItems on my tab control. I am binding my tab control to a collection to generate the TabItems. I have a TabItem style that uses a ContentPresenter to display the TabItem text in a TextBlock. When I bind the tab items to m...

Access Elements inside a DataTemplate... How to for more than 1 DataTemplate?

I've got 2 DataTemplates defined for a Listbox Control. 1 Template is for the UnSelected State and the other one is for the Selected State(showing more detail than the UnSelected State). I followed the example here: http://blogs.msdn.com/b/wpfsdk/archive/2007/04/16/how-do-i-programmatically-interact-with-template-generated-elements-pa...

Binding DataTemplates (or another aproach)

Hi all, I'm having some troubles trying to dynamically generate content in WPF and after it bind data. I have the following scenario: TabControl - Dynamically generated TabItems through DataTemplate - inside TabItems, I have dynamic content generated by DataTemplate that I wish to bind (ListBox). The code follows: ::TabControl <Ta...

How to access the DataTemplate of a DataObject that has the DataTemplate with DataType assigned?

Hi guys, I have a DataObject and a DataTemplate that has the DataType=x:Type DataObject. I have a ContentControl which has as Content the DataObject. On OnContentChanged() of that ContentControl I need to access smtg from the DataTemplate of the new Conten which is a DataObject. How can I do this? Inverse, If I have a UIObject and ...

Targetting DataTemplate for only on certain views

I have a DataTemplate inside a global/shared ResourceDictionary like this which targets a DataType: <DataTemplate DataType="{x:Type foo:Bar}"> <!-- My DataTemplate visual tree goes here... --> </DataTemplate> This DataTemplate replaces my all foo:Bar types on all my Views (UserControls/Windows). What I want to do is to apply this ...

Problem in ListBox ItemTemplate binding using XML as itemssource

I'm having a bit o' trouble... Here is my "mappings.xml" file... <?xml version="1.0" encoding="utf-8"?> <mappings> <mapping QID="info1"> <empty></empty> </mapping> <mapping QID="info2"> <empty></empty> </mapping> </mappings> My method that loads the XML and sets it as the ItemsSource for the listbox: (Note: I didn't ...

WPF Pass current item from list to usercontrol

I am binding to an ObservableCollection<Stage> Stages as the ItemsSource for an ItemsControl: <ItemsControl ItemsSource="{Binding Path=Stages}"> Is there any way to pass the current stage object to a usercontrol in an item datatemplate like this: <ItemsControl ItemsSource="{Binding Path=Stages}"> <ItemsControl.ItemTemplate> <DataTempl...

In WPF how to bind a collection within the parent control's itemssource.

I'm new to WPF so this may be easier than it seems. I have a DataTable object that I set as the itemssource of a combobox. For each row in the DataTable I want a ComboBoxItem. For each ComboBoxItem I want to create a label for every column name and a text box for the corresponding value, in the current row, of that column. Nothing I try ...

WPF DataTemplate property set at Content

New to WPF and have Tabs and in each tab the content is presented in a curved corner panel/window/whateveryouwannacallit. I wasn't sure how to do this ( Style, ControlTemplate ) but decided to go the DataTemplate way. So now I have this DataTemplate: <DataTemplate x:Key="TabContentPresenter" > <Border Margin="10" Border...

In WPF how to change a DataTemplate's Textblock's text binding in code?

I have a ListBox whose ItemsSource is bound to a list of objects. The Listbox has a ItemTemplate with a DataTemplate containing a TextBlock. The textblock's Text is bound to the object's Name property (i.e. Text="{Binding Name}"). I would like to provide a radio button to show different views of the same list. For example allow a us...

How to Automatically Use a DataTemplate Based on ControlControl's Current Content's DataType

When I attempt to specify multiple DataTemplates for use by a ContentControl so that the correct one (based on Type) is used, I end up with Content that is simply the Content's ToString() value. <ContentControl DataContext="{Binding MyTreeRootViewModels}" Content="{Binding /, Path=CurrentlySelectedTreeViewModel}"> <ContentControl.Reso...

WPF - Any ideas why datatrigger not firing?

My listbox is defined below. "Properties" is a BindingList which I am changing one of the items but the Image style is not being updated. Any ideas what I might be missing? <ListBox x:Name="lstProperties" Margin="0,0,5,0" ItemsSource="{Binding Properties}" Sel...

Silverlight 4 and DataTemplate.Triggers

Hi All, I'm trying to show the Master/details scenario in SL4. I have a DataGrid as master and ContentControl as the Child/detail and I want is to select the ContentTemplate to be picked up based upon the [ProductTemplate] Property Value of the currently Selected Item in the DataGrid. Also within that DataTemplate I have DataForm and a ...

TreeView of many types with Master/Detail edit problems!

I have a TreeView wich has many types of items but they all inherit from a base class. Besides the TreeView there is a MasterDetail view for the selected item. Below the MasterDetail view I wan't to have a edit button that changes the MasterDetail view into edit view. I'm doing this by having the master detail view as a ContentPresente...

Silverlight 4 DataTemplate DataType

Silverlight 4 is out and it seems we've missed the DataTemplate DataType functionality in this release again, which is pretty pivotal for MVVM support IMHO. For my WPF apps, at this point, I'm pretty used to globally adding DataTemplates for my Views to my Application.Resources with DataTypes for my corresponding ViewModels: ie. <DataT...

[WPF] DataTemplate inside HierarchicalDataTemplate

I needed to build a custom treeview as a user control. I called it for the sake of the example TreeViewEx : <UserControl x:Class="WpfApplication4.TreeViewEx" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="root"> <...

Add mouse binding on data template using code only

Hi, I'm trying to make data template using a template selector. There is the code of my class : public class ModelTemplateSelector : DataTemplateSelector { public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container) { Type type = item.GetType(); Type listGen...

DataTemplate DataType usage WPF

I had been setting the DataContext for UserControls like so: <uc:DepartmentListingView DataContext="{Binding ., Mode=TwoWay}" /> Based on a sample project by Josh Smith I am trying to accomplish the same thing with a DataTemplate and DataType: <!-- Template applies a DepartmentListingView to an instance of the DepartmentSelectionView...