wpfdatagrid

wpf datagrid alternate row coloring

戏子无情 提交于 2019-12-17 15:46:36
问题 I have tried this method.. without luck.. <Style TargetType="{x:Type DataGridRow}"> <Style.Triggers> <Trigger Property="ItemsControl.AlternationIndex" Value="0"> <Setter Property="Foreground" Value="Red" /> </Trigger> </Style.Triggers> </Style> Is there a way to get the row Index? I have even tried <DataTrigger Binding="{Binding AlternationIndex}" Value="0"> <Setter Property="Foreground" Value="Green"></Setter> </DataTrigger> 回答1: Unless already done, you have to set the AlternationCount

wpf: DataGrid disable selected row styles - or row selecting

廉价感情. 提交于 2019-12-17 11:17:28
问题 I am seeing a lot of examples on how to style Selected rows in DataGrid such as this one: How can I set the color of a selected row in DataGrid Can i just disabled selected row styling? i don't want to have to override every single thing that selected row changes. Just don't want any visible changes. Gotta be easier way than to create templates.. or.. disable selecting rows, if that is easier.. but from browsing this forum that seems hacky as well Disable selecting in WPF DataGrid 回答1:

wpf: DataGrid disable selected row styles - or row selecting

家住魔仙堡 提交于 2019-12-17 11:16:06
问题 I am seeing a lot of examples on how to style Selected rows in DataGrid such as this one: How can I set the color of a selected row in DataGrid Can i just disabled selected row styling? i don't want to have to override every single thing that selected row changes. Just don't want any visible changes. Gotta be easier way than to create templates.. or.. disable selecting rows, if that is easier.. but from browsing this forum that seems hacky as well Disable selecting in WPF DataGrid 回答1:

WPF DataGrid validation errors not clearing

眉间皱痕 提交于 2019-12-17 10:46:07
问题 So I have a WPF DataGrid , which is bound to an ObservableCollection . The collection has validation on its members, through IDataErrorInfo . If I edit a cell in a way so as to be invalid, and then tab away from it before hitting enter, then come back and make it valid, the cell will stop showing invalid, however, the "!" at the head of the row will still be there, and the ToolTip will reference the previous, invalid value. 回答1: Not using Mode=TwoWay for DataGridTextColumns solves one version

How to bind xml to the WPF DataGrid correctly?

a 夏天 提交于 2019-12-17 07:34:38
问题 I have looked for and tried various solutions but so far none of them solve my problem. I am using the built-in DataGrid from WPF in Visual Studio 2010/.NET4 to display data from an XML document stored as an XDocument. My code all runs fine, and I have verified that the XDocument is present and correct. The DataGrid does not display any data, however. The XML looks like this (simplified for clarity): <data> <track> <id>211</id> <name>Track Name</name> <duration>156</duration> <artist_id>13<

Add a checkbox in WPF datagrid header and use it to select/unselect all checkboxes in DataGridCheckBoxColumn

[亡魂溺海] 提交于 2019-12-14 03:59:47
问题 I am new to WPF and would appreciate help on following problem. In my wpf datagrid I have DataGridCheckBoxColumn as first column and I have bind this column to IsSelected property in ViewModel. <toolkit:DataGridCheckBoxColumn Header="Title" Binding="{Binding isSelected}"/> I also want to have a checkbox in header row and which I intend to use to select/unselect all the checkboxes in this column. Till now I have managed to get a checkbox in header by applying a headerstyle as shown in below

DataGrid - how to make Column sorting dynamic, to cater for when bound data changes?

陌路散爱 提交于 2019-12-14 03:16:23
问题 I'm using a DataGrid in a VS2010 WPF C# project. I have bound the DataGrid to an ObservableCollection. When you click on a column heading it sorts the data at that point in time. Question - How would I arrange such that the sorting in the DataGrid is dynamic, so that when data changes (within the ObservableCollection) the sorting keeps working. Notes: Binding approach is via DataGrid private ObservableCollection<SummaryItem> _summaryData = new ObservableCollection<SummaryItem>();

control RadioButton DataGridTemplateColumn from code

烂漫一生 提交于 2019-12-14 02:36:38
问题 i have a datagrid that contains 3 DataGridTemplateColumns that hold radioButtons. now i want to control the "isEnabled" property of the radioButtons from a click event of a button in my code behind: <DataGrid AutoGenerateColumns="False" Height="300" x:Name="dgEmps" RowEditEnding="gridEmps_RowEditEnding" CellEditEnding="gridEmps_CellEditEnding" FlowDirection="RightToLeft" SelectionChanged="gridEmps_SelectionChanged"> <DataGrid.Columns> <DataGridTemplateColumn Header="Shift Manager">

How can I prevent row selection in the WPF Toolkit DataGrid?

只愿长相守 提交于 2019-12-14 01:01:51
问题 I see a few options available for row selection, but 'No Selection' is not one of them. I've tried handling the SelectionChanged event by setting SelectedItem to null, but the row still seems selected. If there is no easy support for preventing this, would it be easy to just style the selected row the same as an unselected one? That way it could be selected, but the user has no visual indicator. 回答1: You have to call DataGrid.UnselectAll asynchronously with BeginInvoke to get it to work. I

Column Headers Offset From Data in Wpf Datagrid

旧巷老猫 提交于 2019-12-13 18:25:58
问题 Good morning I have a Wpf datagrid that is displaying an observable collection of a custom type I group the data using a collection view source in XAML on two seperate properties, and I have styled the groups to display as expanders. For clarity, as there is a lot of data I feel I have to use margins and spacing otherwise things look very cluttered. My problem is that with two levels of hierarchical expanders the column data is now substantially offset from the column headers meaning that