wpfdatagrid

WPF DataGrid Multithreading Crash

拟墨画扇 提交于 2019-12-12 00:23:45
问题 I have a View with a DataGrid in it. A ViewModel as DataContext where i can access a DataTable in a background object. The background object has to work with the DataTable and keep it updated. The user has also be allowed to make changes to that DataTable . If i create a copy of the DataTable it stops crashing but the user is obviousely not working on the data. If i leave access open for the user the program crashed inevitabely. Here is a short program that will crash: app.cs public partial

WPF MVVM Dynamically bind datagrid columns to collection

落花浮王杯 提交于 2019-12-12 00:08:47
问题 I have a request where I need to design a WPF screen using MVVM. This screen has two DataGrids. The first datagrid will be bound to a collection where the datagrid will be able to add or remove items from it. Now, the tricky part is that I need the second DataGrid to have its columns automatically generated from the items in the collection that the first datagrid is bound to. Example: If the first DataGrid has three lines: | Value 1 | | Value 2 | | Value 3 | I need my second datagrid to have

WPF Datagrid scrolls up a bit when scrolled to end

橙三吉。 提交于 2019-12-11 17:59:57
问题 I have a WPF Datagrid (4.0 on Win7). When it is scrolled to very end by dragging (after dragging) the thumb it sometimes returns a bit when released and mouse cursor moves away (probably to start with a complete line). I tried to set CanContentScroll property of DG_ScrollViewer (see WPF DataGrid : CanContentScroll property causing odd behavior) but the grid become unusably slow when populated with lot of data. The problem doesn't occur when scrolling is done by mouse wheel (after scrolling

WPF Datagrid column total sum

帅比萌擦擦* 提交于 2019-12-11 17:25:58
问题 I have a datagrid and I want to sum up all the values in a column. I think, to do this I need to sum the values in that column row by row. But I cant access rows because Datagrid.Rows code in c# does not work in WPF. I access total items count with: datagrid.Items.Count; How can I do datagrid colums total sum in WPF? Datagrid xaml code: <DataGrid BorderThickness="0" Name="grid_lab" RowHeight="25" IsReadOnly="True" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeColumns="True"

scrollable gridview with fixed searched row in datagrid using wpf

谁说我不能喝 提交于 2019-12-11 14:11:37
问题 I'm trying to implement a "find" feature where the user can enter a value in a textbox (outside of the grid) then click a button to find the row that matches the search criteria. if the search item is found in the gridview that searched record has been fixed at top of the gridview and the remaining records are scrollable except the searched record . i need to show this criteria in wpf .please any one suggest me... Thank you in advance.. 回答1: You will have a data grid on your view (xaml and

Why does the Tahoma font render faster than Arial in WPF?

旧城冷巷雨未停 提交于 2019-12-11 13:19:21
问题 I encountered this phenomenon in a mature application that I work on where the Tahoma font in WPF is much faster than Arial. I built a test application to verify what I was seeing. The test application has a TabControl with several TabItems. Each tab contains a DataGrid control and is populated with 18 columns. The grids/columns are all databound to the same viewmodel. The only difference whatsoever between the tabs are the fonts used. There are 1000 rows. The TextBlock sizes are fixed to the

selection change in wpf template combo box column changes values in other rows

南笙酒味 提交于 2019-12-11 12:51:05
问题 In my project I have a data grid with three combo box template columns and are data bound to three collections and these columns are editable. The collection in the second and third combo box is selected based on the selected index of the combo box in first column when I change selection in first column in any row the change is reflected in all rows. here is my xaml code <DataGrid x:Name="dtg" Grid.Row="2" AutoGenerateColumns="False" CanUserAddRows="True" IsReadOnly="False"

'System.Windows.Data.BindingListCollectionView' view does not support filtering

荒凉一梦 提交于 2019-12-11 11:27:44
问题 I have a datagrid and a combobox in my application. I have to filter the datagrid on combobox selected item, I tried to implement the CollectionViewSource.Filter Event in my app, but I get this error. what I have done : Code-behind : private CollectionViewSource logViewSource; IEnumerable<LogEntry> Query; DB_Entities db = new DB_Entities(); private void Window_Loaded(object sender, RoutedEventArgs e) { this.Query = db.LogEntries; this.logViewSource=(CollectionViewSource)(FindResource(

wpf DataGrid change wrapping on cells

冷暖自知 提交于 2019-12-11 11:00:45
问题 I have a WPF DataGrid with AutoGenerate Columns. I have been able to override the column headers using code and also force wrapping on the column headers when I shrink the columns. When I try to force text wrapping on the cells my binding breaks... it shows the same value in every column. Here is the XAML I am using to format <DataGrid.CellStyle> <Style TargetType="DataGridCell"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <TextBlock TextWrapping="Wrap" Text="{Binding}">

Setting max autogenerate width on autogenerated columns in a datagrid

痴心易碎 提交于 2019-12-11 08:37:54
问题 I have a DataGrid that I'm binding to DataTable that got filled by a SQL query. I would like the columns of this grid to be auto-generated with a width of up to a certain number of pixels, but still be expandable by the user if they want it to be wider. Currently the ColumnWidth property on the datagrid is set to SizeToHeader (which doesn't seem to work as described anyway, since it's still sizing to cell content). Is there any way to set a max generation width? Setting MaxColumnWidth