wpfdatagrid

How to Select All check box together in WPF datagrid

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 17:27:25
问题 my wpf data grid is, <dg:DataGrid.Columns > <dg:DataGridTemplateColumn> <dg:DataGridTemplateColumn.Header> <CheckBox Content=" Slect All" Click="CheckBox_Click" /> </dg:DataGridTemplateColumn.Header> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <CheckBox Name="chkSelectAll" Margin="45 2 0 0" Click="chkSelectAll_Click" /> </DataTemplate> </dg:DataGridTemplateColumn.CellTemplate> </dg:DataGridTemplateColumn> <dg:DataGridTemplateColumn Header="Edit Row" > <dg:DataGridTemplateColumn

WPF hide row in datagrid based on condition

谁都会走 提交于 2019-12-21 07:00:09
问题 I need to hide rows in datagrid based on parameters and values in the datagrid. I figured to do something like this; foreach (System.Data.DataRowView dr in myDataGrid.ItemsSource) { //Logic to determine if Row should be hidden if (hideRow == "Yes") { //Hide row code } } I just cannot figure how to actual hide the row. Please note I don't want to remove the row form the datagrid or the item source. 回答1: If hideRow is not a field of the table (i.e. not a column in the DataGridRow): <DataGrid

WPF globally styling a TextBlock inside a DataGrid

点点圈 提交于 2019-12-21 03:46:15
问题 I am encountering a very weird issue. I am trying to apply global styling to several controls within a DataGrid . Most of them work exactly how I would expect them to. However, the styling for the TextBlock never gets applied. Styles for ComboBox , TextBox , Label , and several others all are getting applied to their respective controls, but not the TextBlock . I have simplified the code as much as possible and the issue is still present. I have provided the code sample below. I need the

Why is DataAnnotations <Display(Name:=“My Name”)> ignored when using a DataGrid with AutoGenerateColumns=“True”

自闭症网瘾萝莉.ら 提交于 2019-12-20 14:24:54
问题 I'm using the WPF DataGrid to bind to a collection of a custom class. Using AutoGenerateColumns="True" in the grid XAML, the grid is created and populated just fine, but the headings are the property names, as one would expect. I tried specifying <Display(Name:="My Name")> from the System.ComponentModel.DataAnnotations namespace and that has no effect. I also tried <DisplayName("My Name")> from the System.ComponentModel name space but still the headings are not affected. Is there no way to

Why is DataAnnotations <Display(Name:=“My Name”)> ignored when using a DataGrid with AutoGenerateColumns=“True”

ε祈祈猫儿з 提交于 2019-12-20 14:24:19
问题 I'm using the WPF DataGrid to bind to a collection of a custom class. Using AutoGenerateColumns="True" in the grid XAML, the grid is created and populated just fine, but the headings are the property names, as one would expect. I tried specifying <Display(Name:="My Name")> from the System.ComponentModel.DataAnnotations namespace and that has no effect. I also tried <DisplayName("My Name")> from the System.ComponentModel name space but still the headings are not affected. Is there no way to

WPF Datagrid binding custom column headers

别来无恙 提交于 2019-12-20 10:10:48
问题 I am trying to figure out how to bind a WPF DataGrid's column header and main data to a data source using an MVVM pattern. The result I'm looking for would look like this: (source: vallelunga.com) I've successfully styled the headers here, but I'm unsure how to bind the values in the headers. Specifically, the IsChecked property of the check-box, the selected index of the combo box and the value of the text box. I was previously using a simple DataTable to populate the main grid data, but I'm

How to display Enum type in DataGridTextColumn?

血红的双手。 提交于 2019-12-20 05:46:05
问题 I've List and i bind these list to datagrid that is working fine, but in that Rule class i've one enum type Which is "Type" so in the datagrid i'm getting Type column as empty so how can i get enum type in datagrid column plz help me. Thanks, @nagaraju. 回答1: Usually its should be converted to Its String repersentation directly by binding... but if not the you can write a Value Converter public class EnumConverter : IValueConverter { #region Implementation of IValueConverter /// <summary> ///

How to change a single datagrid row FontWeights to Bold?

北战南征 提交于 2019-12-20 04:36:23
问题 When a row is selected in my datagrid and a button is pressed, I want to change the FontWeight of the cells in that row to bold. I've been looking for a way to do it, but all I can do is change the style of every columns, I can't find a way to get the selected row (or any rows for that matter). There are no specific values that I can bind to from the ItemSource type, so a solution using XAML and a ValueConverter is unwanted due to the increased complexity. That is, unless it's the only way.

How to change single cell color of datagrid in wpf?

主宰稳场 提交于 2019-12-20 03:16:54
问题 I want to change background color of a particular cell of this grid at runtime(show booked seats).i am binding this grid from datatable on window loaded event.i have a record of seats like 'A33'.my code for binding is like this. MySqlConnection mycon = new MySqlConnection(str); mycon.Open(); MySqlDataAdapter da = new MySqlDataAdapter("select * from Stage", mycon); da.Fill(dt); MyGrid.ItemsSource = dt.DefaultView; 回答1: Your cell-data should have a property IsBooked , then in the DataGrid

How to change the image of WPF datagrid row depending on binding value

半腔热情 提交于 2019-12-19 10:00:12
问题 I am a beginner to WPF . I have a data grid for showing messages with column definitions as below . Data grid is bound to a datatable <my:DataGridTextColumn Binding="{Binding Module}" Header="Module" Width="75" IsReadOnly="True"></my:DataGridTextColumn> <my:DataGridTextColumn Binding="{Binding Record ID}" Header="RecordID" Width="75" IsReadOnly="True"></my:DataGridTextColumn> <my:DataGridTextColumn Binding="{Binding ItemName}" Header="Item/Platform/Country Name" Width="175" IsReadOnly="True">