wpfdatagrid

Multi-level header GridView WPF

核能气质少年 提交于 2019-12-09 11:29:11
问题 I need to set the listview view to a gridview that have a complex header like this (based on a 3 dimensional object list i created): | ---------- LEVEL 0 ------------ | | -- Level 1a -- | -- Level 1b -- | | Lvl A | Lvl B | Lvl A | Lvl B | EDIT: This is more ore less my object model public class Measures { public string Caption { get; set; } public List<Threshold> ThresholdList { get; set; } } public class Threshold { public string Caption { get; set; } public double Value1 { get; set; }

How to detect if an item in my ObservableCollection has changed

北战南征 提交于 2019-12-09 04:38:39
问题 I have a datagrid which is bound to ObservableCollection<Product> . When the grid is updated this automatically updates the Product object in my collection. What I want to do now is to have some sort of even that is triggered when any object in the collection is updated -or- some sort of binding to the collection that will return true/false depedant on if any Product has been updated. The overall objective is to have a save button on my main window that is disabled if no changes have been

How to bind DataGridTemplateColumn.Visibility to a property outside of DataGrid.ItemsSource?

倾然丶 夕夏残阳落幕 提交于 2019-12-09 02:29:37
问题 I need to bind the Visibility of a DataGridTemplateColumn to a property outside of the DataGrid.ItemsSource ,because i need to bind this column in the all the rows to one property inside the ViewModel ,but as far as i know you just can bind that to something inside the ItemsSource or you should use ElementStyle and EditingElementStyle I've Already tried this code: <DataGridTemplateColumn Header="post" Visibility="{Binding DataContext.ProjectPostVisibility , RelativeSource={RelativeSource Mode

WPF Datagrid using MVVM.. is two way binding to DataTable possible?

[亡魂溺海] 提交于 2019-12-08 20:24:27
I have a datagrid in my View with it's ItemSource bound to a DataTable in my ViewModel. When I update the DataTable programmatically (adding a column through a command) the changes are not populated to the View. Also, if I invalidate the View, by switching to another tab and then switching back, the changes made are shown. My ViewModel inherits from INotifyPropertyChanged, and I am raising the PropertyChanged event correctly since I use the same process for other bound properties in the ViewModel and they work as expected. Is it possible to get the datagrid to reflect changes I've made to the

WPF Datagrid: SelectionChanged event isn't raised when SelectionUnit=“Cell”

泪湿孤枕 提交于 2019-12-08 17:53:35
问题 I'm using the WPF toolkit datagrid. I have it set to SelectionUnit="Cell" and SelectionMode="Extended" . The SelectionChanged event is never raised! It works fine when the SelectionUnit is set to FullRow. Am I Missing something? BTW, the reason I need it is since I'm trying to create an Attached Property to help me bind the SelectedCells to my ViewModel. 回答1: Make use of DataGrid.SelectedCellsChanged which should provide you with what you need. private void DG1_SelectedCellsChanged(object

WPF Datagrid template removes ability to resize columns

有些话、适合烂在心里 提交于 2019-12-08 17:38:27
问题 How come whenever I override the default template for a DataGridColumnHeader it can no longer be resized by the user even though CanUserResizeColumns is set to true for the datagrid? Is there something that I need to add to the template to restore this functionality? Here's my template xaml: <Style x:Key="ColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="DataGridColumnHeader"> <Border BorderThickness="1"

WPF Datagrid: Clear column sorting

允我心安 提交于 2019-12-08 15:13:50
问题 I am using a WPF Datagrid in my application where columns can be sorted by clicking on the header. I was wondering if there was any way to clear a column's sorting programatically ? I tried sorting a column and then clearing MyDataGrid.Items.SortDescriptions , but that collection was empty (even though one column was sorted). I also tried : MyDataGridColumn.SortDirection = null; The problem is that the column indication is gone, but the sorting still occurs when editing a cell and switching

How to delete selected rows (using checkbox) in wpf datagrid

孤者浪人 提交于 2019-12-08 13:35:10
问题 My WPF DataGrid is: <dg:DataGrid Name="datagrid1" Grid.RowSpan="1" VerticalAlignment="Stretch" Grid.ColumnSpan="2"> <dg:DataGrid.Columns > <dg:DataGridTemplateColumn> <dg:DataGridTemplateColumn.Header> <CheckBox Content=" Slect All" x:Name="headerCheckBox" /> </dg:DataGridTemplateColumn.Header> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <CheckBox Name="chkSelectAll" Margin="45 2 0 0" IsChecked="{Binding IsChecked, ElementName=headerCheckBox, Mode=OneWay}" /> </DataTemplate> </dg

Filtering Datagrid Binded to DataTable WPF

三世轮回 提交于 2019-12-08 12:10:59
问题 I am trying to create a filtering system for a DataGrid in WPF just as in the link - http://www.codeproject.com/Articles/42227/Automatic-WPF-Toolkit-DataGrid-Filtering I am using the same library that they are using but the thing is I need to bind my DataGrid to a datatable... And there is where the error is.. the filter library works perfectly as long as the ItemSource is a LIST but stops to work when the ItemSource is a DataTable... Any Alternatives or Suggestions??? Working Examples

WPF Datagrid using MVVM.. is two way binding to DataTable possible?

牧云@^-^@ 提交于 2019-12-08 08:56:13
问题 I have a datagrid in my View with it's ItemSource bound to a DataTable in my ViewModel. When I update the DataTable programmatically (adding a column through a command) the changes are not populated to the View. Also, if I invalidate the View, by switching to another tab and then switching back, the changes made are shown. My ViewModel inherits from INotifyPropertyChanged, and I am raising the PropertyChanged event correctly since I use the same process for other bound properties in the