datatemplate

WPF TabItem Custom ContentTemplate

I have been strugging with this for a while, it would have been simple to do in WindowForms. I am making a IRC Client, there will be a number of Tabs one for each channel connect to. Each Tab needs to show a number of things, UserList, MessageHistory, Topic. In WindowForms i would just have inherited from TabItem, added some Custom Pro...

How and when to dynamically add columns to a Grid in WPF

Hi we are trying to add ColumnDefinition to a Grid in WPF dynamically from code behind. The question is: when do you do that? In the Usercontrol's Loaded event? We have a ListView that utilizes a DataTemplate which in turn uses the Grid. How do you access that Grid instance (the one inside a DataTemplate) from code behind? It does have ...

How can I change the visibility of elements inside a DataTemplate when a row is selected in a Silverlight datagrid?

I'm using the MVVM pattern. I've bound my items and I want to only show the edit button when a row is selected in the datagrid. It appears to be possible with triggers in WPF but we don't have triggers in Silverlight. I tried a TemplatedParent binding but I'm not sure what the TemplatedParent is in this case. We don't have RelativeSource...

WPF TabBarControl Setting Focus to element when tab changes

I have a TabControl that is bound to a view model <TabControl ItemsSource="{Binding Path=ViewModelCollection}" > <TabControl.ItemContainerStyle> <Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}"> <Setter ...

wpf: usercontrol vs. customcontrol performance issue

Which one is better from performance view user control or custom control? Right now I am using user control and In a specific scenario, I am creating around 200(approx.) different instances of this control but it is bit slow while loading and I need to wait atlest 20-30 second to complete the operation. What should I do to increase the p...

WPF - Getting the value of one a DataGridCell from within DataTemplateSelector

Hi, I'm using DataTemplateSelector with the WPFToolkit DataGrid. I want to select the editing template for one cell based on the value of another cell on the same row. The DataTemplateSelector's SelectTemplate method takes two arguments: one is the data item displayed by the grid row, the other is the grid cell. What I want to know is...

How to declare combobox itemTemplate that has Itemsource as Enum Values in WPF?

I have a enum let's say enum MyEnum { FirstImage, SecondImage, ThirdImage, FourthImage }; I have binded this Enum to my combobox in XAML. While defining an combobox I have defined an ItemTemplate of combox to take Two UI element: TextBlock that show the enum value (Description) Image I have done this much in XAML. I am...

WPF: how to find an element in a datatemplate from an itemscontrol

Hi, I have the following problem: the application is using the custom itemscontrol called ToolBox. The elements of a toolbox are called toolboxitems and are custom contentcontrol. Now, the toolbox stores a number of images that are retrieved from a database and displayed. For that I use a datatemplate inside the toolbox control. However,...

Why is the SelectTemplate Method run 2 times in debug mode?

Hello, debuging this class the SelectTemplate Method is run 2 times, but why? The first time the item is always null. public class PersonDataTemplateSelector : DataTemplateSelector { public override DataTemplate SelectTemplate(object item,DependencyObject container) { if (item is Person) { Person pe...

WPF / Silverlight Binding when setting DataTemplate programically

I have my little designer tool (my program). On the left side I have TreeView and on the right site I have Accordion. When I select a node I want to dynamically build Accordion Items based on Properties from DataContext of selected node. Selecting nodes works fine, and when I use this sample code for testing it works also. XAML code...

Binding from DataContext in Blend 3

i'm trying to build a simple application, that changes images based on Selected item in ListBox. <Grid> <Grid> <Image /> </Grid> <ListBox /> </Grid> The XAML looks similar to this. So i set DataContext of the "inside" Grid to the ListBox's SelectedItem property. The problem is that when i try to DataBind Image source p...

DataTemplate defined in XAML has null VisualTree

I'm using WPF with .NET 3.0. I have a relatively simple DataTemplate defined as the CellTemplate for a GridView. I expect the DataTemplate's VisualTree property to contain a FrameworkElementFactory, but the property is null when I try to access it from the GridViewColumnHeader.Click event. Why is the VisualTree null? I need to access...

Why do I get a NullReferenceException when using a style on a ContentPresenter?

I've created this template, which uses a style applied to the ContentPresenter so that I can bind the data object's Column property to Grid.Column, allowing the items to determine for themselves which column of the Grid they go into: <DataTemplate DataType="{x:Type local:MyObject}"> <ItemsControl ItemsSource="{Binding Items}"> <It...

How do I manually manage the generation of cell visuals with a GridViewColumn.CellTemplate?

I'm using WPF with .NET 3.0. I have a DataTemplate defined in XAML. I have a ListView with a GridView. I'd like to be able to generate the cell visuals with DataTemplate.LoadContent(), and insert the result into the GridView cell when needed. I need to do this so that I can set additional bindings on the generated visual object. Is ...

ContentTemplateSelector is only called one time showing always the same datatemplate

Hello, I have made a sample demo VS 2010 RC sample project, because in my production project I have the same error using MVVM. In my sample demo project I use only Code-behind without 3rd party dependencies so you can download the demo project here and run it for yourself: http://www.sendspace.com/file/mwx7wv Now to the problem: When ...

DataTemplate, Style, Triggers

Could you guys help me? I have a with custom and in it: <ListBox> <ListBox.ItemTemplate> <DataTemplate> <Border BorderBrush="Black" BorderThickness="2" CornerRadius="5"> <Image Source="{Binding Picture}" /> </Border> </DataTemplate> </ListBox.ItemTe...

Validation (with custom ErrorTemplate) for a DataTemplate

I can't figure this guy out / in desperate need of assistance. I have an ItemsControl and a DataTemplate as the ItemTemplate i.e. <DataTemplate> <StackPanel> <TextBox Text={Binding Prop1}/> <TextBox Text={Binding Prop2}/> </StackPanel> </DataTemplate> I have seen plenty of examples for applying validation to th...

Datatemplates while using theme does not work - WPF

I am using the theme DarkExpression from WPF Futures. It does not seem to work well with datatemplates. Scenario 1: Here is how it looks like without datatemplates: Pic 1 Code: <ListView Name="playlistListView" ItemsSource="{Binding PlaylistList}" Margin="0" SelectionChanged="DatabindedPlaylistListView_SelectionChanged" Background="...

WPF - data binding trigger before content changed

How do i create trigger, which fires BEFORE binding changes value? How to do this for datatemplate? <ContentControl Content="{Binding Path=ActiveView}" Margin="0,95,0,0"> <ContentControl.Triggers> <--some triger to fire, when ActiveView is changing or has changed ?!?!? --> </ContentControl.Triggers> public Object...

WPF: HierarchicalDataTemplate ItemsPanel

I have a TreeView which uses a custom ItemsPanel to show the first level of items in a StackPanel, but I need to show subitems in a StackPanel too. The problem is, the second level of items are shown in a WrapPanel, and as HierarchicalDataTemplate doesn't have an itemsPanel property I'm not sure how to do this. This is my xaml: <TreeVie...