itemscontrol

WPF - Why do ContextMenu items work for ListBox but not ItemsControl?

Items in a list have context menus. The context menu items are bound to routed commands. The context menu items work correctly if the list control is a ListBox, but as soon as I downgrade it to an ItemsControl it no longer works. Specifically the menu items are always greyed out. The CanExecute callback in my CommandBinding is not be...

Bind the height of a grid row to it's contents in WPF

I have a grid with a few rows. In the top row, I have an ItemsControl that is bound dynamically to a collection and uses a DataTemplateSelector and ItemsPanelTemplate (with a single horizontally arranged WrapPanel). Here's a stripped-down version of what I have so far: <Grid> <Grid.RowDefinitions> <RowDefinition Height="40...

Putting a scoll bar on a wrap panel contained within an items control

Hi, Does anybody know how I can add a scroll bar to a wrappanel contained within an itemscontrol? ...

WPF ItemsControl: Where is my memory leak?

sample demo solution: http://cid-e8bbd1bbd58dbc88.skydrive.live.com/self.aspx/.Public/Stuff/GMapNET%20wpf%20leak%20test.zip image: Press END to add 1000 items and remove them. Any ideas where it is leaking memory? void MainWindow_PreviewKeyUp(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.K...

Implement SelectedValues property on WPF control

I'm working on creating a CheckedComboBox WPF control. I want to add a SelectedValuesProperty that I could bind through via XAML. I've tried a few different things and haven't been able to get it to work yet. Does anyone have any suggestions on how to approach this? My control inherits from MultiSelector. Thanks in advance! This is ...

Should my ViewModel have an ObservableCollection of Views or ViewModels?

I'm trying to understand the basic MVVM design approach when using ItemsControl by binding it via DataTemplates to ObservableCollections on the ViewModel. I've seen examples that bind to ObservableCollections of strings, Views, and ViewModels. Binding to strings seems to be only for demos, it is the binding to "ViewModels that contain ...

WPF DataTemplate: How to create a tooltip just-in-time?

I am using DataTemplates to render items in an ItemsControl. I want to show a tooltip for each item. If I use a binding such as ToolTip="{Binding MyToolTip,Mode=OneWay}", WPF gets the tooltip once at the beginning and does not update the tooltip when it is opened. My items implement INotifyPropertyChanged, so in principle I could genera...

WPF - Border around an itemscontrol

Hey, I have an itemscontrol with a custom panel inside a usercontrol. The usercontrols size is only constrained by the parent window size. <UserControl> <Grid> <Border BorderBrush="DarkGray" BorderThickness="5"> <ItemsControl ItemsSource="{Binding ActiveGame.Grid.CellsFlat}"> <ItemsControl.ItemsPanel> <Ite...

Listbox scrollbar thumb changes size when content is variable height

I have a ListBox with many objects displayed, each of which can be a variable height, based on the number of values each object has. See my previous question that was answered here. Many objects are 5-lines high, while others are 1. The scroll bar in the ListBox does not appear to like this, probably due to the virtualization. While you...

Finding control within WPF itemscontrol

Hi i have few a single textbox within the the datatemplate for itemscontrol. When i binf the itemcontrols to a observable collection i get two text boxes. But i need to do some manipulations based on each of the text boxes for which i want to find each textbox seperatly using some id. Can anybody help on how to find a control witin the ...

Getting UI Element that has keyboardFocus from itemscontrol

Hi I have a itemscontrol that displays some textboxes dependning on the observable collection items in viewmodel. I need to determine the textbox that has keyboard focus on click of a button outside the itemscontrol. Problem: 1. When i click the button the keyboard focus shifts to button instead of the textbox. 2. How can i get the a ...

Problem with WPF Keyboard Focus in itemControl

Hi I have a WPF window which is divided into two portions. One portion contains itemscontrol which generate textboxes depedning on observable collection binding in ViewModel. The other portion of window has a content control which loads a usercontrol using datatemplate and viewmodel binding. Also that user control has buttons on it. ...

access-like data navigation in WPF?!

What would be the best way to build a data-navigation like in access-forms in XAML/C#? Should I build a user control (or even custom control) that I just bind to my collection in which I can put other controls? (hence this question: http://stackoverflow.com/questions/969835/c-user-control-that-can-contain-other-controls-when-using-it ) ...

Synchronizing WPF control widths in a WrapPanel

I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth="200" /> </WrapPanel> I want all the CheckBoxes inside the WrapPanel to be the same width. Adding the following almost accomplishes the desired e...

WPF Error: "Items collection must be empty before using ItemsSource."

Hello, Does anyone know why I keep getting the "Items collection must be empty before using ItemsSource"-Error? Here is the code: <ScrollViewer Margin="8,8,8,8" Grid.Row="3" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"> <WrapPanel Orientation="Vertical"> ...

Bind Dictionary to ItemsControl in C#/WPF

Hello, I'm trying to bind KeyValuePair Elements from a Dictionary to a ItemsControl. My Dictionary has 15 Elements and the following code shows me 15 TextBoxes: <WrapPanel Name="PersonsWrapPanel" Grid.Row="0"> <ItemsControl ItemsSource="{Binding Persons}" > <ItemsControl.ItemsPanel> <...

How to draw line of ten thousands of points with WPF within 0.5 second?

I am writing WPF code to show a real-time plot which is a connected line containing about 10,000 points. It takes about 5 seconds to show a picture in my computer. Does anyone have an idea to make it quicker and within 0.5 second? class eee : FrameworkElement { public eee() { _children = new VisualCollection(this); ...

WPF Tab Into Databound ItemsControl

In my WPF application, I have a databound TextBox and a databound ItemsControl. The contents of the ItemsControl is determined by the contents of the TextBox. I want to be able to type a value into the TextBox, press tab and enter the first item in the ItemsControl (created from the value in the TextBox ). The problem I am having is tha...

Why would ItemsControl show a view but ContentControl show nothing?

I've got an application based on Prism. This is my shell: <Window x:Class="AvarioCRM3.ShellV2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cal="http://www.codeplex.com/CompositeWPF" > <DockPanel LastChildFill="True"> <Border ...

WPF - How to stop an ItemsControl psuedo-grid's columns from dancing/jumping around during layout

Several other questions on SO have come to the same conclusion I have -- using an ItemsControl with a DataTemplate for each item constructed to position items such that they resemble a grid is much simpler (especially to format) than using a ListView. The code resembles: <StackPanel Grid.IsSharedSizeScope="True"> <!-- Header --> <G...