itemssource

Custom collection crashes DataGrid on Edit

微笑、不失礼 提交于 2019-12-06 01:27:12
问题 Im currently trying to bind the DataGrid.ItemsSource to a custom RowCollection, which implements IList and INotifyCollectionChanged: Public Class RowCollection(of T) Implements IList(Of T) Implements INotifyCollectionChanged Private _List As New List(Of T) ... (Sorry for the VB code, I'll be translating all my code to C# soon.) Notice the class does not derive from any existing CLR collection. I created my own class because I need to override GetItemAt, in order to implement record paging.

WPF ComboBox Doesn't Display SelectedItem after one DataTrigger but does for another

你离开我真会死。 提交于 2019-12-05 11:17:14
So I have a combobox I'd like to reuse for multiple sets of data rather than having 3 separate comboboxes. Maybe this is bad and someone can tell me so. I'm open to all ideas and suggestions. I'm just trying to clean up some code and thought one combobox rather than 3 was cleaner. Anyway the ItemsSource and SelectedItem all should change when another ComboBox's value is changed which Raises the Property Changed value for the ComboBox that isn't working. The worst part is when CurSetpoint.ActLowerModeIsTimerCondition is true it always loads the SelectedItem correctly but when going from that to

Unreasonable WPF DataGrid Loading Time

强颜欢笑 提交于 2019-12-05 02:48:38
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 simple layout, the DataGrid populates instantaenously, whereas the code below takes around 3 seconds to execute. In the following code, it takes ~3 seconds for 150 rows and 11 columns to load, even if each cell is not bound to any property and with AutoGenerateColumns=False. (I have a two core, 2.6GHz processor with plenty of RAM). The bottle neck

COMBOBOX filtering in WPF with MVVM

断了今生、忘了曾经 提交于 2019-12-04 14:55:12
I am developing an application using WPF mvvm approach. I have a requirement where I have to show a list of items in a combo box for selection. Based on some flag I need to filter out few items from the combo box for selection. I tried to use two different items sources one with full list and another with filtered list and based on the flag I wanted to change the items source. This does not seem to be working well. Is there any easy way to apply filters on the existing list based on some flag ? There are lots of different ways to do this but my personal preference is to use a

Show if ItemsControl.ItemsSource is null

走远了吗. 提交于 2019-12-04 08:32:31
Greetings, I have a ItemsControl which template I changed to show a RadioButton for every object in the binded ItemsSource. However the ItemsSource can be empty and when it is empty I'd like to show a default value. Something like "The binded list contains no items for you to select"... One way I thought of is to set the ItemsControl.Visibility to Collapsed and have a TextBlock.Vsibility to Visible which shows the text.. But this would include a lot more data. Is it possible to show a default value if the ItemsControl.ItemsSource is null? If I understood correctly, I think you can solve your

Custom collection crashes DataGrid on Edit

放肆的年华 提交于 2019-12-04 05:46:12
Im currently trying to bind the DataGrid.ItemsSource to a custom RowCollection, which implements IList and INotifyCollectionChanged: Public Class RowCollection(of T) Implements IList(Of T) Implements INotifyCollectionChanged Private _List As New List(Of T) ... (Sorry for the VB code, I'll be translating all my code to C# soon.) Notice the class does not derive from any existing CLR collection. I created my own class because I need to override GetItemAt, in order to implement record paging. The Collection Internally adds and removes objects from its own private List _List . Now, I am able to

How to load ItemsSource before setting SelectedItem in ListView?

只愿长相守 提交于 2019-12-04 05:28:41
问题 I have a MVVM page that contains a ListView . I bind ItemSource and SelectedValue , but first time it calls converter for SelectedValue then loads ItemSource . <ListView x:Name="ListViewSurahs" ItemsSource="{Binding MyItems}" FlowDirection="LeftToRight" Grid.Column="2" Grid.Row="4" VerticalAlignment="Top" HorizontalAlignment="Left" HorizontalContentAlignment="Center" SelectionMode="Single" ScrollViewer.VerticalScrollBarVisibility="Auto" DisplayMemberPath="Name" SelectedValuePath="ID"

WPF DataGrid cannot Add a row when datasource is empty

久未见 提交于 2019-12-04 03:04:03
问题 CanUserAddRows="True" only 'works' when there's already data in the ItemsSource of the DataGrid . If it just so happens that there are no rows in the original list of items, then the DataGrid doesn't display a placeholder row for entering new items, even though I've set CanUserAddRows="True" . Why?! Thanks in advance, Trindaz 回答1: This seem to be a known issue with WPF DataGrid. See discussion here (starting from the 4th comment) Also it seem to be fixed in .net 4. I've made some tests for

WPF - reset ListBox scroll position when ItemsSource changes

偶尔善良 提交于 2019-12-03 22:52:40
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 collection of items and scroll to the bottom of the ListBox, and then change the reference to another collection containing, say, 1 item, the ListBox view is blank and no scrollbar is displayed. I have to then scroll the listbox up with the mouse wheel, until the 1 item comes into view. So, what I think I'm after, is a way of resetting the scroll position

GridView column width does not update when changing ItemsSource

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 21:23:53
问题 I have a GridView where I'm setting the ItemsSource in code-behind. All columns in the grid are defined in XAML, and all column widths are "Auto". When I initially set ItemsSource of the grid, the column widths are set correctly. Now, depending on the user's actions, the ItemsSource of the grid may be set to a new EntityCollection. What I have noticed is that the column widths remain as they were with the previous ItemsSource. That is, the column widths don't seem to adjust themselves