wpfdatagrid

Making a row non-focusable in a WPF datagrid

◇◆丶佛笑我妖孽 提交于 2019-12-01 09:17:26
I'm trying to figure out how to make the rows in the following WPF DataGrid non-focusable. As you can see I tried adding a <DataGrid.Resources> section to the DataGrid where I'm specifying a DataGrid cell style but this isn't working. What am I missing? <DataGrid Name="grdResources" AutoGenerateColumns="False" SelectionUnit="FullRow" AlternatingRowBackground="LightBlue" CanUserDeleteRows="False" CanUserAddRows="False" CanUserReorderColumns="False" ClipboardCopyMode="ExcludeHeader"> <DataGrid.Resources> <DataGridTemplateColumn.CellStyle> <Style TargetType="DataGridCell"> <Setter Property=

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

跟風遠走 提交于 2019-12-01 09:04:22
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"> </my:DataGridTextColumn> <my:DataGridTextColumn Binding="{Binding DateReceived}" Header="DateReceived"

How i set a DataTable to be the ItemsSource of a DataGridComboBoxColum?

為{幸葍}努か 提交于 2019-12-01 08:56:09
问题 I have a DataTable with two Columns that i will bind to all the ComboBoxes of a DataGridComboBoxColumn where one of the Columns will be the Text of the Items, and other will be the Values of the Items. I know that the property called 'DisplayMemberPath' is where i specify the Name of the Column to be the Text of the Items, and to the values it have to be specified in the 'SelectedValuePath' property. But one more time it's a problem to Bind whatever to a DataGridComboBoxColumn because it can

Get the multiple selected Row in data-grid in WPF?

纵然是瞬间 提交于 2019-12-01 07:22:57
问题 I want to get the multiple selection of data-grid in WPF, as my the business requirement I have a customer table in data grid which allows multiple selection and radio button (ALL, Selected, All but selected). If the selected or all but selected is clicked the I have to pull data only for those customers which are selected in the data- grid. Please advice solution to get multiple selected row of data grid. Thanks. 回答1: I have got a solution for the above question, //CustomerDTO is the DTO

“Two-way binding requires Path or XPath” when edit wpf datagrid

六眼飞鱼酱① 提交于 2019-12-01 05:11:12
ContractListUserControl.XAML <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Path=ContractList}" SelectedItem="{Binding Path=SelectedContract}"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding Path=Person.LastName}" Header="Last Name" /> <DataGridTextColumn Binding="{Binding Path=Person.GivenName}" Header="Given Name" /> <DataGridTextColumn Binding="{Binding Path=ContractStart, StringFormat=dd/MM/yyyy, Mode=TwoWay}" Header="Contract Start" /> <DataGridTextColumn Binding="{Binding Path=ContractEnd, StringFormat=dd/MM/yyyy, Mode=TwoWay}" Header="Contract End" /> </DataGrid

“Two-way binding requires Path or XPath” when edit wpf datagrid

老子叫甜甜 提交于 2019-12-01 03:28:45
问题 ContractListUserControl.XAML <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Path=ContractList}" SelectedItem="{Binding Path=SelectedContract}"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding Path=Person.LastName}" Header="Last Name" /> <DataGridTextColumn Binding="{Binding Path=Person.GivenName}" Header="Given Name" /> <DataGridTextColumn Binding="{Binding Path=ContractStart, StringFormat=dd/MM/yyyy, Mode=TwoWay}" Header="Contract Start" /> <DataGridTextColumn Binding="

WPF Datagrid “Select All” button - “Unselect All” too?

会有一股神秘感。 提交于 2019-12-01 03:20:41
I would like to know if it would be possible to add functionality to the 'Select All' button in the top left of a datagrid so that it also unselects all rows? I have a method attached to a button which does this, but it would be great if I could fire this method from the Select All button, to keep functionality in the same part of the view. Can this 'Select All' button have code added to it, and if so, how would one get to the button? I haven't been able to find any examples or suggestions. WillH OK after a lot of searching I found out how to do get to the button from Colin Eberhardt, here:

DataGridTemplateColumn with DatePicker requires three clicks to edit the date

假装没事ソ 提交于 2019-11-30 21:50:27
I have a DataGridTemplateColumn . Inside its CellEditingTemplate , I put a DatePicker control. Now if I want to edit the date, I have to click three times to let DatePicker begin editing. Can someone let me know how I can get DatePicker into edit mode with only two clicks? Also, if DataGridTemplateColumn get focused, keyboard typing doesn't put DatePicker into edit mode as well. It would be nice if it can be fixed as well. biju You have to override the PrepareCellForEdit in DataGridTemplateColumn as follows: public class DataGridDateColumn:DataGridTemplateColumn { protected override object

ColumnHeader arrows not reflected when sorting a DataGrid in XAML

走远了吗. 提交于 2019-11-30 20:41:13
I have a DataGrid with some sorting defined in XAML like so: <CollectionViewSource x:Key="DefaultSort" Source="{Binding SearchResults}"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="ExternalOrgNo" Direction="Ascending"/> <scm:SortDescription PropertyName="ExternalBranchNumber" Direction="Ascending"/> </CollectionViewSource.SortDescriptions> </CollectionViewSource> The sorting is properly applied to the DataGrid but there is no indication of the sorting on the grid. Looking at the view in the code behind I see the SortDescriptions in the collection and I've tried

Is There A Way To Style A WPF DataGrid NewItem Placeholder

北城以北 提交于 2019-11-30 19:53:26
I have a simple data control defined as follows <DataGrid x:Name="ScheduleDataGrid" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" Margin="5" ItemsSource="{Binding ScheduleItems}"> <DataGrid.Columns> <DataGridTextColumn...></DataGridTextColumn> .... <DataGridTextColumn...></DataGridTextColumn> </DataGrid.Columns> </DataGrid> I have specified CanUserAddRows="True". As advertised, this puts a blank row at the bottom of the grid for the user to add a new row. Is there a way to style that new item placeholder independently of the rest of the grid? Yes it is possible to