wpfdatagrid

WPF DataGrid - Can't Use Mouse To Scroll Because Of Drag Drop

孤者浪人 提交于 2019-12-13 18:03:29
问题 I am using a datagrid that is allowing to drag its rows. My problem is that when i try to scroll down on my grid using the mouse on the side scroller, i get the 'no enterance' sign that means that "drag and drop is not allowed here, dude...". How can i modify my drag and drop function to recognize that this is not a drag and drop action, but a scroll mouse action? private new void MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { Point

WPF Datagrid. Get the values of each cell of the selected row

a 夏天 提交于 2019-12-13 15:12:55
问题 I'm using the WPF toolkit DataGrid. How can I get the values of the cells of the selected rows? 回答1: In WPF rows represent objects in a list and columns are object's properties. It depends on what DataGrid.ItemsSource is.If your ItemSource is an array of BindedClass you could get selected object by: BoundClass bc = (BoundClass)dataGridControl.SelectedItem; var prop1 = bc.Prop1; var prop2 = bc.Prop2; 来源: https://stackoverflow.com/questions/1570929/wpf-datagrid-get-the-values-of-each-cell-of

Showing a new Window right next to a DataCell in DataGrid (WPF)

本小妞迷上赌 提交于 2019-12-13 12:21:23
问题 I want a scenario when a user clicks on a cell in DataGrid in WPF, I want to open NumPad next to it (This is basically for touch based input). The NumPad, I understand is a separate window. 1) How can I know which Cell is selected 2) how can I show the NumPad next to the cell? 3) How can I find the coordinates of cell to position my NumPad? 4) How can I set the value of cell based on NumPad entry? NumPad is a WPF User Control in the same application. DataGrid is a .NET 4 Control. It's a

How to bind an enumerator or variable to a DataGridComboBox in DataGrid in WPF?

亡梦爱人 提交于 2019-12-13 05:43:47
问题 I want to put the contents of an enumerator, or some array of strings or a specific DataTable as the items of a DatagridComboBox, so how i can bind the enumerator or the array of strings or a DataTable contents to a DataGridComboBox? For example, i have a Datatable i will load to a DataGrid and will bind the records to customized columns, and depending on value of the cell (from the Datatable) when the column (in the DataGrid) is a DataGridComboBox it will auto-select the corresponding item

DataGridTemplate column with textbox not retaining the value in the datagrid column field

﹥>﹥吖頭↗ 提交于 2019-12-13 03:59:03
问题 I wanted a text which holds only 10 characters as max length in it. As I found that normal Datagrid textcolumn doesnot have maxlength property I went for Template column. But for the below xaml code. The data is not saving back to the binded field and its showing the old value. Can anyone give a helping hand. <Grid Background="#FFF0F0F0"> <DataGrid AlternatingRowBackground="#FFE9FFE9" AlternationCount="1" AutoGenerateColumns="False" PreviewKeyDown="DgvDiagramNo_PreviewKeyDown" CanUserAddRows=

How to get only modified Items from WPF Data Grid

帅比萌擦擦* 提交于 2019-12-13 03:24:43
问题 I have binded a list with Editable WPF DataGrid I want to get only the modified Items from the WPF Data Grid for updation. Please let me know how to do this. 回答1: I have my WPF datagrid app set up as so: 1) Manually defined all the columns, set their bindings and for each binding specified that it notifies on source updates 2) Added an event handler for the datagrid's SourceUpdated event 3) In the event handler I have only the following code: this.updatedItems.Add(BindingOperations

Editing a DataGrid in WPF causes a System.NullReferenceException

ε祈祈猫儿з 提交于 2019-12-13 03:17:37
问题 I have a simple application that reads a list of Albums from a DataBase and fills a ListBox (AlbumShowCase). Whenever a ListBoxItem is selected I update a DataGrid (trackDataGrid) with the list of tracks in that Album (also from the DataBase). The problem is, I can edit the items in the DataGrid, and for all the existing tracks, changes are persistent. But if I try to add a new track, once I finish editing the row I get the System.NullReferenceException. private TunesDBDataContext db; private

WPF- How to get selected row index in datagrid?

时光毁灭记忆、已成空白 提交于 2019-12-13 02:39:33
问题 I have the textbox in datagrid. Data are taking from database. assume I have 10 rows with these textbox value. once I click on this row, able to get this selected row index. My goal is if once textbox value are get change, I need to detect which row it is (which value)and do some calculation based on this value then need to display another field of the same row. So I am in a position to know which row being get hit. `I am using Datagrid with following declarations: <dg:DataGrid Name=

Collection was modified when trying to remove selected items of datagrid

谁说我不能喝 提交于 2019-12-13 01:11:46
问题 by following this answer I coded almost same way. Below is part of my code. XAML binding: <cst:CustomDataGrid x:Name="grdItems" ItemsSource="{Binding myItems, IsAsync=True}" SelectedItemsList="{Binding SelectedItems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ViewModel: Protected Overrides Sub DeleteCurrent() Dim msg As New UserMessage() If SelectedItems IsNot Nothing Then For Each SelectedItem In SelectedItems myItems.Remove(SelectedItem) Next RaisePropertyChanged("Items") End If End

Disable DataGridCell if another cell is being used

两盒软妹~` 提交于 2019-12-13 00:38:51
问题 On a row inside of a datagrid, I'm trying to disable a cell/field if the cell next to it is being used or vice verse. In other words the user can only enter one or the other, if the user enters info into one cell the other should be disabled or readonly or something. How can I achieve this? Can I somehow create a converter? At the same time the user should be able to zero out that cell in case he didn't mean to enter info in that cell. Any advice is much appreciated. <DataGridTextColoumn