Questions tagged [itemssource]

374 questions
48
votes
10 answers

ItemContainerGenerator.ContainerFromItem() returns null?

I'm having a bit of weird behavior that I can't seem to work out. When I iterate through the items in my ListBox.ItemsSource property, I can't seem to get the container? I'm expecting to see a ListBoxItem returned, but I only get null. Any…
Sonny Boy
  • 7,848
  • 18
  • 76
  • 104
37
votes
2 answers

Why are DataContext and ItemsSource not redundant?

In WPF Databinding, I understand that you have DataContext which tells an element what data it is going to bind to and ItemsSource which "does the binding". But e.g. in this simple example it doesn't seem that ItemsSource is doing anything useful…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
27
votes
2 answers

How to setup a grid as template for an Items control?

I'm trying to create an ItemsControl that uses a grid as its ItemsPanel in such a way that it has two columns, where the first columns width is the width of the widest item in that column, and has as may rows needed to display all the…
pastillman
  • 1,104
  • 2
  • 16
  • 27
25
votes
3 answers

Custom ItemsSource property for a UserControl

Does anyone know how to make a custom ItemsSource? What I want to do is to make an itemsSource to my own UserControl so that it could be bound by ObservableCollection<>. Also, I could know Whenever the number of items in the itemsSource updated, so…
user1184598
  • 449
  • 1
  • 5
  • 11
22
votes
1 answer

Difference between ItemsSource and DataContext as pertains to ListBox

I am not quite grokking the difference between ItemsSource and DataContext. Can someone explain it and back it up with examples? When would I use one or the other. I am reading the docs and it says that I can bind using DataContext, but I throw an…
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
18
votes
5 answers

WPF - reset ListBox scroll position when ItemsSource changes

I currently have a ListBox whose ItemsSource collection is bound to a property on my viewmodel, of type IEnumerable. When that preoprty's reference changes, the ListBox updates as expected, however I have a problem in that if I have a large…
devdigital
  • 34,151
  • 9
  • 98
  • 120
14
votes
3 answers

set xaml code ItemsSource="{Binding}" with code behind

I have the following property Temp2: (my UserControl implements INotifyPropertyChanged) ObservableCollection _Temp2; public ObservableCollection Temp2 { get { return _Temp2; } …
Tono Nam
  • 34,064
  • 78
  • 298
  • 470
13
votes
2 answers

WPF - Combobox SelectedItem not getting set?

I have a ComboBox that has its ItemsSource bound to a static List of options. The ComboBox is part of a form which is bound to a CustomObject class, and one of the properties on that class is a CustomSettingProperty. I would like to…
Rachel
  • 130,264
  • 66
  • 304
  • 490
12
votes
1 answer

IsSynchronizedWithCurrentItem attribute and current item updates

I have a view model to manage a dialog type of view that allows filtering of a listing (if necessary) and selection of an item. The code works fine whether I set IsSynchronizedWithCurrentItem to true or not. My understanding is that this property is…
Berryl
  • 12,471
  • 22
  • 98
  • 182
11
votes
1 answer

WPF Binding ItemsSource to a static method?

I have the following static method in an class called "Article" : public static ObservableCollection
GetObservableCollection() { ... } And I'd like to bind this directly to the ItemsSource property of a ComboBox but in the XAML not in…
Karnalta
  • 518
  • 1
  • 9
  • 24
11
votes
3 answers

Binding to DataContext outside current ItemsSource context

I have a DataSet bound to the Window.DataContext; I also have a DataGrid:
vuduy
  • 121
  • 1
  • 1
  • 6
11
votes
6 answers

WPF DataGrid: DataGridComboxBox ItemsSource Binding to a Collection of Collections

Situation: I've created a DataGrid in XAML and the ItemsSource is binded to an ObservableCollection of a certain class that contains properties. Then in C#, I create a DataGridTextColumn and a DataGridComboBoxColumn and binded these to the…
Partial
  • 9,529
  • 12
  • 42
  • 57
10
votes
4 answers

Unreasonable WPF DataGrid Loading Time

I've always had long loading times with WPF DataGrids, and I cannot find any similar reports online, so I suspected that I was doing something wrong. Now I am sure of it, since adding layout complexity considerably slows down execution. In a very…
Eugenio De Hoyos
  • 1,755
  • 16
  • 22
10
votes
1 answer

IEnumerable property without type

I'm trying to make a property like the official DataGrid.ItemsSource, from MSDN: public IEnumerable ItemsSource { get; set; } This provides the support of any type, in any derived class. With this, I can set something like var list = new…
Guilherme
  • 5,143
  • 5
  • 39
  • 60
10
votes
3 answers

Keeping Focus/SelectedItem after DataGrid ItemsSource change

ive been working on this for a few days, but cant seem to come up with a solution i have code on a timer that refreshes the DataGrid every few seconds i tried many refresh options, but in the end they all lose the users focus and sometimes also the…
Yisroel M. Olewski
  • 1,560
  • 3
  • 25
  • 41
1
2 3
24 25