wpfdatagrid

WPF Datagrid not respect change of item property value

Hi all, my problem is here: I have some class public class Component { ... private ServiceController service; ... public int ServiceStatus { get { switch(service.Status) { case ServiceControllerStatus.Stopped: return 0; case...

How to loop over the rows of a WPF toolkit Datagrid

Hello WPF experts: I have the next code where I defined a WPF toolkit datagrid control called dgQuery; I filled this one with information of a dataset, then I inserted a new checkbox column in dgQuery to check/uncheck some of the rows, I show part of my C# code: dgQuery.DataContext = dS.Tables[0]; DataGridTemplateColumn cbCol = new D...

WPF DataGrid load issue

First off I have a datagrid on the main form which is populated with about 7000 rows. It is bound (to ItemsSource) in the forms constructor. Everything runs extremely fast and smooth when the app loads (less than 1 sec). However when I want to load that same datagrid in another window it takes > 1 min. There is no difference in the x...

DataGridCell.IsEditMode?

How Can I know if the DataGridCell is currently in edit mode (not IsSelected), I mean, for example a DataGridTextColumn cell is clicked it becomes a TextBox and not a TextBlock, that's what I call IsEditMode. I wanna set a trigger-setter for this mode. EDIT: I tried to set a general style for DataGridCell.IsEditing but it doesn't seem t...

Make individual checkboxes on WPF datagrid not visible

I have a datagrid bound to a CollectionViewSource view in my view model. The datagrid has a CheckBoxColumn and three TextColumns, each bound to properties in the items in the view. I also have a bool property "Enabled" in the view item that I would like to use to make checkboxes in individual rows not visible. As an added bonus, it wo...

WPF DataGrid - Dynamic Row Details via Code

I have the need to show RowDetails in the WPF DataGrid when the user performs an action outside of the grid. The thing is though, I need to be able to switch out exactly what the RowDetails will be based on that. For example, if the click Add, I want to show RowDetails below Row of type AddRowDetailControl, and if they choose Edit, I wo...

Causing Row Selection in custom Row Template - MS WPF DataGrid

I have a custom row template to show some data, and it doesn't use a SelectiveScrollingGrid in its' template. I don't mind handling the events on my outer elements, but I can't seem to figure out how to cause a "Select" behavior. Typically I've been causing it by raising the MouseLeftButtonDownEvent on the active DataGridCell, but now th...

Why is ListCollectionView.CustomSort so slow?

I have an ObservableCollection of ViewModels that are sitting in a WPF DataGrid. The DataGrid has three columns: Position column; this is rendered at runtime by a UserControl that displays the position of the row in my DataGrid Name column; this is rendered at runtime by a UserControl that displays the name of the column (yes, I need a...

How to bind WPF Datagrid itemssource to Collection of Collections ?

What is the best approach to bind a WPF DataGrid ItemsSource to an ObservableCollection of ObservableCollections ? e.g. public ObservableCollection<ObservableCollection<MyDataItem>> DataValues = new ObservableCollection<ObservableCollection<MyDataItem>>(); where MyDataItem may look like this: public class MyDataItem { public s...

How to show row index for wpf toolkit datagrid?

I just want to add a index column in wpf toolkit datagrid to show row index of each data in datagrid. How? <dg:DataGrid ItemsSource="{Binding List}" SelectionMode="Extended" IsReadOnly="True" AutoGenerateColumns="False" ...

Coloring WPF DataGridRows one by one

I'm making a WPF program which is able to color the rows in a datagrid one by one in red using the 'for' loop and I've encountered something weird. If the datagrid has more than 40 rows of data from a database table, it doesn't color all the rows. Here's the code I'm using. private void Red_Click(object sender, RoutedEventArgs e) {...

WPF Datagrid Multiple Selection without CTRL or Space

The WPF Datagrid has two selection modes, Single or Extended. The WPF ListView has a third - Multiple. This mode allows you to click and select multiple rows without CTRL or Shift being held down. Anyone know how to do this for the datagrid? ...

WPF DataGrid: how do I stop auto scrolling when a cell is clicked?

Problem: If my DataGrid is not entirely visible (horizontal & vertical scrollbars are showing) and I click on one of my cells that is partially visible, the grid auto-scrolls to bring that cell into view. I don't want this to happen. I've tried playing around with RequestBringIntoView, like this: private void DataGrid_RequestBringIntoVi...

TextChanged/LostFocus/etc. event for DataGridTextColumn

I have a list of object bound to a DataGrid in a WPF page and I am looking to add an object directly after the current one if the value entered in a specific column is less than a certain number. <my:DataGridTextColumn Binding="{Binding Path=Hours}"/> I cannot for the life of me figure out how to bind to an event on the underlying Tex...

Error while setting a Datacontext for a UserControl in WPF

I have usercontrol where I am trying to set the context as below <UserControl.DataContext> <Binding ElementName="dataGrid" Path="MyViewModel"> </Binding> </UserControl.DataContext> Here dataGrid is a child DataGrid control and MyViewModel is my ViewModel class. Currently its giving following error while runtime: Cannot find ...

WPF Datagrid using MVVM.. is two way binding to DataTable possible?

I have a datagrid in my View with it's ItemSource bound to a DataTable in my ViewModel. When I update the DataTable programmatically (adding a column through a command) the changes are not populated to the View. Also, if I invalidate the View, by switching to another tab and then switching back, the changes made are shown. My ViewModel ...

WPF Toolkit: DataGrid EventHandler for CheckBoxColumn.CheckedChanged?

Hi, I am currently playing around with WPF and the WPF toolkit which contains a WindowsForms-style DataGrid. I have bound a list of custom objects to the grid as ItemsSource. These objects contain two boolean properties which are editable using the datagrid. Synchronising back into my list works fine using the build-in databinding mode...

WPF DataGrid Templates for sets of columns

I want to change the content of the data grid column definition based on state in the ViewModel or based on the data bound to the DataGrid. How do I do this via templates and template selectors? I want to write xaml and not code in order to do this. Ex: there are two subclasses A and B that have 5 common columns and 5 completely diffe...

WPF Datagrid : Programatically bringing a column into view (horizontal scroll)

I would like to bring a column into view programatically. I have a lot of columns and when they are off screen i would like to select a cell and bring that cell into view, i can select a cell that is off screen and when i horizontal scroll to bring the cell visible the cell is selected. i know you can do this with the rows, i.e Scroll...

Disable tabstop between columns in a WPF datagrid

I have a WPF Toolkit datagrid with mulitple columns. I am trying to get a behaviour where you can tab into the grid using tab, then tab out again using a single tab. E.g. I do not want to tab through all the columns or cells of the grid, just once in, and once out. Is there a simple solution, I have tried setting the TabNavigation to On...