itemscontrol

Is hard coded XAML faster than code-behind generated XAML?

I have a WPF usercontrol which contains a number of textboxes and buttons. Currently these textboxes and buttons are all created and loaded dynamically into an ItemsControl through the code behind, whenever an instance of the control is created. The only hard-coded XAML is the declaration of the ItemsControl. This can be a bit sluggish ...

How do you call identically named properties on different types which don't share an interface?

I have a DataTemplate that needs to set the IsSelected property on an ItemsControl's container (such as TreeViewItem, ListViewItem or ComboBoxItem). However, it doesn't know the type of the container until it's passed in to it. Since IsSelected isn't part of a common base class or interface, nor is it a common dependency property regis...

MVVM-PRISM, how to display multiple instances of a view in a region/ItemsControl

Hi! I am building an module for an application that is based on MVVM, CAL and PRISM. I'm fairly new to these concepts, and trying to get my head around all the patterns and right now I'm struggling with the following problem: I am in the need of creating multiple instances of the same View. Each one of the views need to bind to it's o...

[WPF] ItemsControl : how to do hittest to find item / index under mouse position ?

In my Canvas I have children with a specific design which includes an ItemsControl. In the OnPreviewLeftMouseButtonDown handler of my canvas, I perform a hittest using VisualTreeHelper, and when I find a specific ItemsControl I'd like to know which item / item-index the mouse was over. Does anybody know how to do this ? ...

SL ItemsControl, command on ViewModel not firing from ItemsControl (CheckBox)

Hi, I'm using PRISM v2, CAL, SL4 and MVVM and have a delegate command on my ViewModel called CheckCommand. The ItemsControl contains a checkbox and I'm trying to get the items in ItemsControl/Checkbox to fire this command when it's checked - but it's not communication back to the viewmodel! I think it's because each items 'datacontext' ...

Wrap something around each item in an ItemsControl

Let's say I have a collection of objects of different classes. Each class has its UserControl DataTemplated in a resource file. Now I want to use ItemsControl to display the collection, but I want an Border or Expander around each item. I would expect something like this to work: <ItemsControl ItemsSource="{Binding MyObjects}"> <I...

How do you arrange items in a table layout in SilverLight?

SO I am stumped. I've got a collection of items that I'm binding to an ItemsControl and would like them arranged as a grid rather than strictly vertically or horizontally. All of the examples I've used in WPF are not supported in Silverlight like using the ItemContainerStyle or SharedSizeGroup and the Silverlight toolkit WrapPanel does n...

Creating a dynamic grid control

Hi all. While working in WPF i have the need for a Dynamic Grid. By this i mean a grid that contains only one kind of object, has a template for that object etc. But unlike a similar ItemsControl like a Listbox, i want the grid to be given a Maximum Columns property. This should act as a delimiter which will then calculate the number of ...

PRISM-MVVM, ItemsControl problem with View injection

Hi, I need to display multiple instances of a basketDetailsView.xaml within a region placed in basketView.xaml, but I'm getting the following errormessage when i debug my code: "An exception occurred while creating a region with name 'basketRegion'. The exception was: System.InvalidOperationException: ItemsControl's ItemsSource propert...

Custom control not applying template in itemscontrol

I have written a fairly simple timeline control which extends control. It has a generic template that displays correctly when the control is used by itself. I have put the control in an ItemsControl and now no templates are being applied to the timeline (OnApplytemplate() isn't firing). I cannot for the life of me figure out what the pr...

Is there a way to visualize an ItemTemplate in WPF

I have an ItemsControl that has a fairly complex ItemTemplate which allows the user to edit an Order. Unfortunately the design surface in Visual Studio does not show the ItemTemplate so I don't get an instant feedback of the changes I make. Is there a way to visualize the ItemTemplate in Visual Studio? Here's the structure of my control:...