WPF Datagrid cell tooltip - wpf

I have a WPF 4.0 DataGrid displaying data from a LINQ to Entities query. The query returns an anonymous list so the DataGrid has its AutoGenerateColumns property set to true.
How can I display ToolTips for the column cells?

You should probably do this in the column's style. If you want to choose the style at runtime, you can subscribe to the AutoGeneratingColumn event, and customize the column as you like...
Here is a link from on MSDN with a very good tutorial on Customizing AutoGenerated Columns

Related

How can I apply AutoGenerateColumn to apply DataGridTemplateColumn.HeaderTemplate in a DataGrid?

for an overview, an MVVM project in built in WPF.
Basically in my xaml, I have a datagrid bound to a dataview. When my service populates the dataview I get a dynamic table with an arbitrary number of columns.
For each column in the datagrid, I have created a headertemplate which contains a combobox which is bound to an Observable<Dictionary<string,BusinessEntity>> object as its item source in the xaml. Figuring out the combobox is another issue but I am trying to just populate data grid first, then worry about binding the combobox correctly.
anyways the only solution I have somewhat though of was to turn on autogeneratecolumn and then replacing all the headers with a combobox in the codebehind, but then I have issues trying to bind the combobox in the codebehind correctly and it doesn't feel MVVM if I have to create all those comboboxes there.
You can handle the AutoGeneratingColumn event to customize the auto generated column's header template.

Columns definition for DataGrid bound to DataTable with unknown columns?

I have a DataTable which is going to be bound to a DataGrid. I don't know what the columns will be in advance, however I do know the first column will be a boolean value that should be bound to a CheckBox.
Is there an easy way to create a DataGrid that will generate the unknown columns, but not show the first column? The unknown columns will need to maintain the sort functionality. AutoGenerateColumns would be nice if I could flag one of the columns as "DoNotShow" or something....
You can handle the AutoGeneratingColumn event of the DataGrid and deny the column from appearing from there: http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.autogeneratingcolumn.aspx
If you don't want to handle it in code-behind, you can 'forward' the event to your view-model with help from a messaging/aggregation framework such as the Messaging system in MVVMLight.

How to reorder WPF Toolkit datagrid colums programmatically?

My application uses the WPF DataGrid control with custom columns. Although the property Columns is an ObservableCollection<>, the invocation of the method Move does not effect the order of the columns in any way.
Can I somehow reorder the columns of a WPF Toolkit DataGrid programmatically?
Best Regards
Oliver Hanappi
You can use the DisplayIndex property of a DataGridColumn (use datagrid.Columns to retrieve the columns collection).

sorting and filtering options in WPF Datagrid?

I installed the most recent WPF toolkit and used the Datagrid control.
The list of items is showing with automatically-generated columns based on my IList as ItemsSource.
I was wondering if there is an OOTB way to have filtering/sorting on this grid?
A way to click the header to make it sort, or use a dropdown in the header that shows all the possible values so that column is filtered on that property.
Right now my grid is just a fancy list of items.
To enable filtering, sorting and grouping, you can use the ICollectionView interface. See this post for more information.
To enable sort when clicking the column header, you can set to true the CanUserSortColumns of the DataGrid control.

WPF Listview

How to create a GridView like view to the WPF ListView if i dont know the Column names at the design time because the collection will be created at runtime and the collection will be of type DataTable and it may contain a no.of columns.I can do it with WPF DataGrid but i want to achieve this with WPF ListView and I want to Achieve this without code behind.
You can add columns dynamically to a ListView by using Attached Properties. Check out this article on the CodeProject it explains exactly that...
WPF DynamicListView - Binding to a DataMatrix

Resources