wpfdatagrid

ColumnHeader arrows not reflected when sorting a DataGrid in XAML

浪子不回头ぞ 提交于 2019-12-19 02:37:32
问题 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

WPF DataGrid - Why the extra column

让人想犯罪 __ 提交于 2019-12-18 18:53:34
问题 I have a WPF app that uses DataGrid to display some data. When I run the program there is an additional column as shown here: Here is what it looks like when I design it in VS2010 I have turned off AutoGenerateColumns on the data grid and specified the columns individually as such (this is a user control): <Grid Margin="10,10,10,10"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition /> </Grid.RowDefinitions> <DataGrid x:Name="EmployeeHours" AutoGenerateColumns="False"

WPF Style Trigger for DataGridRow Background Color Trumped by AlternatingRowBackground Brush

坚强是说给别人听的谎言 提交于 2019-12-18 12:26:38
问题 I have a WPF DataGrid which has an AlternatingRowBackground brush. It's configured to color every other row. I'd like to do something on mouse over that highlights the current row. However, the Style Trigger seems to be losing out to the AlternatingRowBackground brush. I get the desired row coloration on the mouse over... but only on the rows that are not painted with the AlternatingRowBackground brush. Here is the Style in Windows.Resources: <Window.Resources> <ResourceDictionary>

how to set focus to particular cell of WPF toolkit datagrid

匆匆过客 提交于 2019-12-18 11:51:50
问题 I am using WPF toolkit provided DataGrid control to display product list along with its OpenStock, Description etc. In this DataGrid i have set OpenStock column to editable and rest are non-editable. What i want now when my this windows loads, I want to set keyboard focus to first cell of OpenStock column and if possible in edit mode. I searched this for 2 days and finally posting here. any help or code sample would be helpful. <my:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding}"

Disable DataGrid current cell border in FullRow selection mode

…衆ロ難τιáo~ 提交于 2019-12-18 10:58:37
问题 I am using a DataGrid in row selection mode (i.e., SelectionUnit="FullRow" ). I simply want to remove the border that is being placed around the current cell when the user highlights a row in order to have true full row selection (and no cell level selection). I don't mind the notion of the grid maintaining the current cell, I just want to remove that pesky current cell border, perhaps by changing the style of the current cell. What is the easiest way to do this? 回答1: You could set the

Show “No record found” message on a WPF DataGrid when it's empty

情到浓时终转凉″ 提交于 2019-12-18 05:45:22
问题 If there is no record available, I want to add a TextBlock on data grid, below the header, showing the message "No Record Found." Consider the attached image for reference. 回答1: Its been a long time since the question has been posted. But I thought this might be useful to someone else. <Window.Resources> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> </Window.Resources> <DataGrid Name="dgProjects" ItemsSource="{Binding Projects}" AutoGenerateColumns="True" /> <TextBlock

Code to check if a cell of a DataGrid is currently edited

ぃ、小莉子 提交于 2019-12-18 03:34:43
问题 Is there a simple possibility to check if the DataGrid is currently in EditMode (Without to subscribe to BeginningEdit and CellEditEnding) 回答1: It seems you can also get this information from the items view, namely this works: IEditableCollectionView itemsView = stateGrid.Items; if (itemsView.IsAddingNew || itemsView.IsEditingItem) { stateGrid.CommitEdit(DataGridEditingUnit.Row, true); } I have not confirmed this but most likely you could get these flags in a viewmodel if your bound

Code to check if a cell of a DataGrid is currently edited

China☆狼群 提交于 2019-12-18 03:34:21
问题 Is there a simple possibility to check if the DataGrid is currently in EditMode (Without to subscribe to BeginningEdit and CellEditEnding) 回答1: It seems you can also get this information from the items view, namely this works: IEditableCollectionView itemsView = stateGrid.Items; if (itemsView.IsAddingNew || itemsView.IsEditingItem) { stateGrid.CommitEdit(DataGridEditingUnit.Row, true); } I have not confirmed this but most likely you could get these flags in a viewmodel if your bound

How to add a right click context menu to Column Header for a WPF 4 DataGrid?

為{幸葍}努か 提交于 2019-12-18 03:16:38
问题 I want the context menu for a DataGrid's column headers to be different than the rest of the cells. So using the regular ContextMenu property is not going to work. There is DataGrid.RowHeaderTemplate, but I can't find DataGrid.ColumnHeaderTemplate. Edit/Note: Columns are generated dynamically. 回答1: Target a common Style to all DataGridColumnHeaders: <DataGrid.Resources> <ContextMenu x:Key="DataGridColumnHeaderContextMenu" ...> </ContextMenu> <Style TargetType="{x:Type DataGridColumnHeader}">

Datagrid Column header should check / uncheck CheckBox’s state depending upon whether all CheckBoxes of a DataGridView column are checked or unchecked

江枫思渺然 提交于 2019-12-17 16:30:42
问题 The problem i'm stuck with is related to checkbox in DataGrid(WPF). I've attached the screenshot for better understanding of the problem. Problem: The DataHeader Column Checkbox is checked even when one of the child is Unchecked. I expect the solution to fix this so that when one of the child is unchecked explicitly by the user, The ALL(Column Header) should be unchecked implicitly. Please help guys... Thank You Plz check the link. i want the solution to work like this. http://www.codeproject