wpfdatagrid

DataGrid's CellEditingTemplate and focus in edit mode

可紊 提交于 2019-12-03 05:00:39
I am having an issue with WPFToolkit DataGrid when a column is customized supplying both CellTemplate and CellEditingTemplate . If you take a look below, you will see my editing template has a single CheckBox . All is fine in a functional sense but when F2 is hit to edit the cell, one must also hit TAB in order for the CheckBox to receive focus. Ideally, one would hit F2 and SPACE to toggle the value. Currently, one must hit F2, TAB, SPACE. I have tried setting TabIndex to no avail. I am running out of ideas. <WPFToolkit:DataGridTemplateColumn Header="Turn" MinWidth="60"> <WPFToolkit

How do you rename DataGrid columns when AutoGenerateColumns = True?

你离开我真会死。 提交于 2019-12-03 02:20:57
I have a simple data structure class: public class Client { public String name {set; get;} public String claim_number {set; get;} } Which I am feeding into a DataGrid : this.data_grid_clients.ItemSource = this.clients; I would like to change the column headings. Ie: claim_number to "Claim Number". I know this can be done when you manually create the columns by doing something like: this.data_grid_clients.Columns[0].Header = "Claim Number" However, the Columns property is empty when auto-generating the columns. Is there a way to rename the columns, or do I have to manually generate the columns?

How to add back the sort arrow after applying background of Column headers

前提是你 提交于 2019-12-03 02:19:24
After applying background color to columnheaders, the sort arrow is missing. How to add it back? I think you're gonna have to re-template the DataGridColumnHeader and add it from there. Here's an example. You're gonna have to add a reference to PresentationFramework.Aero xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" <DataGrid ...> <DataGrid.Resources> <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}"> <Setter Property="Width" Value="8"/> <Setter Property="Background" Value="Transparent"/> <Setter Property="Cursor" Value="SizeWE"/>

How to detect if an item in my ObservableCollection has changed

岁酱吖の 提交于 2019-12-03 01:31:00
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 made to my collection and enabled if changes have been made. I have read into INotifyPropertyChange but I

Disable First Column of First Row in WPF DataGrid

北城以北 提交于 2019-12-03 01:16:03
问题 Is there a way (using styles and multi triggers) to always disable the first column of the first row of a DataGrid in a WPF control? This is a templated column which shows combo box in edit mode and text box in normal mode. I'd like this to never go into the edit mode (only this column). The rest of the columns in the row should be able to go into the edit mode. 回答1: Yes, it is possible (in other words you want to disable a definite cell), but I would preferable use ValueConverter or

WPF Datagrid binding custom column headers

橙三吉。 提交于 2019-12-02 21:11:29
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 going to need something more complex to hold both the grid data and the values for each column. Or

How should I cast a DataTable for assignment to DataGrid.ItemsSource?

淺唱寂寞╮ 提交于 2019-12-02 19:53:05
问题 I am trying to learn WPF, and trying to populate a WPF DataGrid with data from a MySQL database. The relevant code is: dataGrid.DataContext = myMySQL.DBDataSet; dataGrid.ItemsSource = myMySQL.DBDataSet.Tables[tblName]; dataGrid is a WPF DataGrid control. myMySQL.DBDataSet is a System.Data.DataSet. I get the following error on the second line of code above. "Cannot implicitly convert type 'System.Data.DataTable' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you

How to Find a Control that is inside DataTemplate & assign Value in WPF?

二次信任 提交于 2019-12-02 16:06:14
问题 I have a DataTemplate which is binded to Grid Group Header Section. There are four TextBlock in DataTemplate from one of TextBlock contains the Grid Header Column Value. Now, I want to Split this TextBlock Value into three and assign this value to other three TextBlock from Code Behind. Is it Possible? <DataTemplate x:Key="descriptionHeader"> <!--<dxg:GroupGridRowContent> <TextBlock Background="Yellow" Text="{Binding DisplayText}" ></TextBlock> </dxg:GroupGridRowContent>--> <Border

Disable First Column of First Row in WPF DataGrid

淺唱寂寞╮ 提交于 2019-12-02 13:40:00
Is there a way (using styles and multi triggers) to always disable the first column of the first row of a DataGrid in a WPF control? This is a templated column which shows combo box in edit mode and text box in normal mode. I'd like this to never go into the edit mode (only this column). The rest of the columns in the row should be able to go into the edit mode. Yes, it is possible (in other words you want to disable a definite cell), but I would preferable use ValueConverter or CellTemplateSelector to reach the goal. In the soution below there is a restriction, that you have to set an

WPF DataGrid Cell Text Wrapping - set to NoWrap (False)

不问归期 提交于 2019-12-02 08:04:25
问题 How do I set the TextWrapping of every cell in a WPF DataGrid to "NoWrap"? I understand the Cell itself does not have a "TextWrapping" property, but I'd like to set the property on the control within the cell. The DataGrid I am working with does not have columns defined explicitly, the result set it is displaying is dynamic. I am looking for a solution similar to the answers provided in the links below. However I do not want to explicitly override the cell style/template and define the