datatemplate

How can I bind a ListBox's items to a List of instance objects?

My code behind file receives an instance object Session which has a property AvailableCountries that returns a List. Each Country object has a Name property which is a String. I also want to display these Country objects using a data template which I simplified here. My current code is after going through a WPF binding tutorial, only t...

Programmatically set content in Silverlight DataGrid details

I need to dynamically set the contents within the template of a DataGrid based on information in an external settings file. That settings file specifies which data fields should display in the DataGrid. The administrator of the application can edit the settings to change the fields to display. I cannot hard-code the fields to display. I...

Can I apply a ContextMenu to a ContextMenuViewModel using a DataTemplate?

I have a ViewModel (AbstractContextMenu) that represents my context menu (IContextMenu), and I bind a real ContextMenu to it with a DataTemplate: <DataTemplate DataType="{x:Type local:AbstractContextMenu}"> <ContextMenu x:Name="contextMenu" ItemsSource="{Binding Path=(local:IContextMenu.Items)}" IsEnabled="{Bind...

Is it Possible to apply a DataTemplate to a Page?

I'm trying to follow the MVVM pattern laid out here: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090097 I have this in my MainWindowResources.xaml file: <DataTemplate DataType="{x:Type vm:VendorsViewModel}"> <vw:Vendors/> <--- I get a "Can't put a page in a style" error in blend with this </DataTemplate> and I'...

'Default' text for templated combo box

I have a combo box that is based on a data template the includes check boxes like such: <ComboBox x:Name="cboComplex" Text="Select days..."> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <CheckBox IsChecked="{Binding Path=IsSelected}" Width="20"/>...

Dynamic (programmaticaly) ItemTemplate (DataTemplate) in Silverlight?

I have this code: <Grid x:Name="LayoutRoot"> <Grid HorizontalAlignment="Left" Height="900" Width="1200"> <Grid.RowDefinitions> <RowDefinition Height="300"></RowDefinition> <RowDefinition Height="200"></RowDefinition> <RowDefinition Height="200"></RowDefinition> </Grid.RowDefinition...

WPF DataTemplate not throwing exception

While designing a new WPF application I noticed exceptions not being thrown during data binding for controls with DataTemplates. To test I wrote the following simple user control with as little logic as possible. I'm using .NET 3.5 SP1, VS2008 SP1 running on WIN7. When the DataContext is set, TestMethod is called and an exception is t...

Silverlight Binding Height to its parent element is not working

<local:CustomDataGrid Grid.Row="0" Height="200" IsReadOnly="True" x:Name="dgCaseHistory" AutoGenerateColumns="False"> <local:CustomDataGrid.RowDetailsTemplate> <DataTemplate> <Grid Background="Black" Height="{Binding ElementName=dgCaseHistory, Mode...

WPF Templates and binding to DataContext in a GridView

I'm trying to create a series of bound columns in a RadGridView, and I'm using a template to create hyperlinks in two of the columns. Here is basically what I have: <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Distributor" DataContext="{Binding Distributor}" CellTemplate="{StaticResource linkTemplate}"/> and, <DataTe...

Silverlight Visual State Manager and DataTemplates

I'm porting a WPF application to Silverlight. DataTemplates in XAML are used to define the visuals for the data objects. In WPF, triggers are defined in the DataTemplates to provide mouse-over effects, etc. This is all done in xaml. I understand that Silverlight does not have triggers, and you are supposed to use the Visual State Manag...

WPF DataTrigger cannot find Trigger Target

<ListBox.ItemTemplate> <DataTemplate> <Grid x:Name="grid"> <Grid.Background> <SolidColorBrush x:Name="backgroundBrush" Color="Transparent" Opacity="0.1"/> </Grid.Background> </Grid> <DataTemplate.Triggers> <DataTrigger Binding="{Binding IsExpanded}" Value="Tr...

WPF: How to access Element in ListView.ItemTemplate ?

I need to access element named "PageHost" for the selected list item in the following XAML code from C# codebehind, how to do so please ? <ListView.Resources> <p:PageWidthConverter x:Key="PageWidthConverter" /> </ListView.Resources> <ListView.ItemTemplate> <DataTemplate x:Name="PagesVi...

[WPF] SelectionChanged of a child ListBox

Hi, I have a ListBox bound to an ObservableCollection with an ItemTemplate that contains another ListBox. First of all, I tried to get the last selected item of all the listboxes (either the parent and the inner ones) from my MainWindowViewModel this way: public object SelectedItem { get { return this.selectedItem; } set {...

Silverlight - Access the Layout Grid's DataContext in a DataGrid CellTemplate's DataTemplate?

Hi, I am using Silverlight 3 to develop an application. In my app, I have a layout Grid (named "LayoutGrid") in which I have a DataGrid (named "PART_datagrid") with DataGridTemplateColumns. The LayoutGrid is set a DataContext in which there is a Ladders list as a property. This Ladders list is set as the ItemsSource for the PART_datagri...

DataGridTemplateColumn for individual control-column vs DataGridTextColumn

Hello, what is the difference, both works: DataGridTemplateColumn versus DataGridTextColumn both works means I can edit+display rich text in the cell. <DataGridTemplateColumn Header="Homework"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <RichTextBox > ...

DataTemplate in ListBox

Hi, I have tabcontrol,in that by pressing second tab button im adding data to third Tab Listbox.But its not get added. SecondTab function: private void Callbutton_Click(object sender, RoutedEventArgs e) { tab.AddPresetmenu("CALL BUTTON"); } ThirdTab Fucntion: ObservableCollection<DataItem> items =...

ComboBox ItemTemplate Containing checkbox bound to object

Hi, I have a combobox whose ItemTemplate is a Checkbox. This is checkbox is bound to an object which has a bool and a string. The checkbox checked state is bound to the bool and the content is bound to the string. I want a select all option at the top of the combobox collection, which has an indeterminate state, according to the other ...

DataTrigger not reevaluating after property changes

[Original] I have a listbox which has its itemssource (this is done in the code behind on as the window is created) databound to an observable collection. The List box then has the following data template assigned against the items: usercontrol.xaml ... <ListBox x:Name="communicatorListPhoneControls" ItemContainerStyle="{Sta...

WPF - Very basic ListBox.ItemTemplate Question

Ok, this is an embarassingly simple-looking problem, but is driving me crazy. I'm learning about DataTemplating and am trying to apply a very VERY simple ItemTemplate to a ListBox. However, when I run my app, the template is completely ignored and I just get the standard-looking listbox, whereas in fact I'd expect to see a list of check...

WPF Some styles not applied on DataTemplate controls

Hi, I am trying to learn something about WPF and I am quite amazed by its flexibility. However, I have hit a problem with Styles and DataTemplates, which is little bit confusing. I have defined below test page to play around a bit with styles etc and found that the Styles defined in <Page.Resources> for Border and TextBlock are not app...