itemscontrol

WrapPanel as ItemPanel for ItemsControl

Still fooling around with WPF and learning as I go. Trying now to build a dynamic grouping of controls ( mostly buttons but might include checkboxes and others ). I had no idea what was the best way to do this so I tried creating a ItemsControl style and then add the items into a itemspresenter inside a wrappanel. Soon realized the item...

How to make ItemsControl choose different templates depending on run-time type.

I have a xaml page that has an ItemsControl control on it. ItemsControl is bound to Guests which is ObservableCollection. Guests collection can have objects of two different types: USGuest and UKGuest, both inheriting from Guest. Is it possible to make two (or more) templates for ItemsControl and make it automatically choose between them...

WPF Populate combo box with multi-table data

Hello: I'm working on a simple WPF example and wanted to expand the example but I'm struggling, I'll explain some background first. I have three tables, people, addresses, and countries. As expected people live at an address, and addresses are located in a specific country. I'm currently working through using a combo box as a lookup t...

How can I get a WPF Window to expand to fit the contents of a dynamically changing ItemsControl?

I've got a WPF application which starts off with a very small window. Something in the area of 200x100. When certain events are raised from an external source, I add a control to the ItemsControl area of my window. The items control is currently set to use a StackPanel PanelTemplate. What I want, is for the application window to grow wh...

WPF: How to use views like ICollectionView and IEditableCollectionView

I understand the syntax but not how really to use it. It's clear in many basic scenarios but as soon as it get's a little bit advanced I start getting a headache. For example there are many different views but often not clear wich one to use. Also should you use always just one or mix and match. Do you use the view as your itemssource f...

ItemsControl - Bind Control's and Backing Collection's Sort Orders Together

Hello, Is there a way to bind an ItemsControl (like ListView or DataGrid) to a sorted collection such that: whenever the collection is resorted via code, the ItemsControl automatically reflects the new sort order, AND whenever the ItemsControl is sorted, it re-sorts the collection? Thank you, Ben ...

Multiple user controls share collection dependency property

Hi, I have implemented my own usercontrol based on listboxes. It has a dependency property with type of a collection. It works fine when I have only one instance of the usercontrol in a window, but if I have multiple instances I get problem that they share the collection dependency property. Below is a sample illustrating this. My user ...

Is binding an ItemsControl to an ObservableCollection<T> more efficient than a List<T>?

I have a render-heavy item template in an ItemsControl and want to minimize the recreation of child item templates when ItemsSource signals a change. I am wondering if, because ObservableCollection can tell WPF precisely what has changed (as opposed to just the whole list), if it is more efficient in rendering changes to the collection, ...

XamlWriter loses binding - ok! but how to keep the value? (ItemsControl)

hi, i know the standard XamlWriter does not persist bindings. but what really stinks is that the current value the binding holds does not get serialized too. my current - really stupid - workaround is to create a DependencyProperty fooProperty and the property foo. and also a property foo2. the Change-eventhandler of foo then writes it...

Style me an ItemsControl subclass please - stuch with ItemsPresenter.

I have an control that is subclassed from ItemsControl, called WorkSheet. public sealed class WorkSheet : ItemsControl { It's elements are forced to be WorkTiles. /// <inheritdoc /> protected override bool IsItemItsOwnContainerOverride(object item) { return (item is WorkTile); } /// <inheritdoc /> protect...

WPF - Best way to remove an item from the ItemsSource

Hi, I'm writing a custom ItemsControl (a tabbed document container), where each item (tab) can remove itself from the UI when the user closes it. However, I can't remove it directly from the ItemsControl.Items collection, because the items can be databound. So I have to remove it from the ItemsSource, which can be anything (ICollection,...

How do I accessing siblings from an Item inside a ItemsControl?

I have an ItemsControl: <StackPanel> <ItemsControl x:Name="TopicList"> <ItemsControl.ItemTemplate> <DataTemplate> <local:TopicListItem Title="{Binding Title}" LocationCloud="{Binding Locations}" TagCloudData="{Binding TagCloudData}" SparklineData="{Binding SparklineData}"/> </DataTempl...

How to increase padding displayed items combobox?

I want to write XAML template of a combobox to increase the spaces/padding between items. I searched for this but almost end up with the ItemsPresenter: <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/...

Dragable objects in WPF in an ItemsControl?

I want to be able to implement an ItemsControl with dragable items. The reason for the ItemsControl is so I can bind to my ViewModel in the background. I've tried using a Thumb Control in a canvas and it works perfect, except as soon as I stick it in an ItemsControl it stops working. Here is what I tried: <ItemsControl ItemsSo...

WPF: Do I really need a DataGrid?

I need not: sorting filtering grouping column headers row headers I need: Just 7 buttons(each a weekday) over the data matrix data Scrollable data matrix editable row AND columns resizeable I decided to choose this: A Scrollviewer with a Grid with several Gridsplitter and a Itemscontrol. Implement IEditableObject into my ViewMo...

How do you get a WPF ItemsControl item to fire a command upon pressing the spacebar?

I have a list of Hyperlinks in an ItemsControl and I would like the user to be able to press the spacebar to invoke the hyperlink's command when the hyperlink has focus (currently pressing enter does this as well - but its not so discoverable IMO). Here's my ItemsControl decl: <ItemsControl x:Uid="_commandsItemsControl" Name="_comm...

WPF - Bind to Item Index from within ItemTemplate of ItemsControl?

Is there a way to bind to the ItemIndex from within the ItemTemplate of an ItemsControl? For example: <ItemsControl ItemsSource="{Binding Path=ItemList}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=ThisItemsIndex}" /> </DataTemplate> </ItemsControl.ItemTemplate> </Items...

ItemTemplate: ListBox vs ItemsControl

Hi, I'm quite new to the WPF world and I'm having some problems with templating items in an ItemsControl. What I need is to template elements (mostly buttons) inside an ItemsControl (or the like). If I'm using the following XAML code ... <ItemsControl> <ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type Button}"> ...

Silverlight 4 memory leak with ItemsControl

In our SL4 application built on Caliburn.Micro, we've come across a (another) memory leak. Stripped out, it seems that the problem is caused by ItemsControl with custom DataTemplate bound to an IEnumerable collection of objects that implement INotifyPropertyChanged interface. When the source collection is changed (another collection is...

Width of items in ItemsControl

I have an ItemsControl with a DataTemplate that is bound to an ObservableCollection of integers. <ItemsControl Name="DimsContainer" ItemTemplate="{StaticResource DimensionsTemplate}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ItemsCont...