WPF Multiline ToolTip with data binding - wpf

In our WPF application we show a data bound GridView, and one of the grid fields is a filter field which is combination of several sub-fields. In the grid, I show a simple string concatenation of the field, but I want the ToolTip to show a formatted presentation of the filter. The formatted presentation might contain some or all of the filter fields.
I can freely change the class bound to the grid.
Can you recommend a way to bind the ToolTip to the data, by adding some sort of a field, so it is nicely displayed, with multiple lines and indentation? I'd like to avoid specifying all the fields I need in the XAML and hide them based on the data, but I will probably do so if I don't come with a better approach. Another option might be to build the ToolTip structure in code in the ToolTipOpening event. Do you have a better idea?

I was having same scenario and was using DataTrigger in the Tooltip's Style to hide and show fields in tooltip based on their values.

Related

Telerik RadGridView data comparison with cell formatting

I have two RadGridViews in my application. Two Grids are pulling the information from two different sources. That information bound to grid view.
Both the sources are of same Type List<MyComplexObject>. Now I wanted to compare these two grids, and color the cells (to Red) in second grid which has the different value.
How can we implement this functionality using Silverlight, C# and Telerik RadGridView?
You could use a Style Selector for the grid you want to have colored in a different way. You would need to prepare a normal cell style and a "Red" cell style as in this example. The article present the complete solution for cell style selector so you will have a full view on how this works. What you would need to do additionaly is to add a property (DependencyProperty) to the style selector to which you would bind the data collection against which you check the cell value validity.

DataGridTemplateColumn Binding Using a TextBox in WPF with MVVM

I have a DataGrid that is bound to a List (ListOne). Inside the grid I'd like to display an extra TextBox that contains fields found in another Class that is not the same as the Class used in ListOne.
I've done this before with a ComboBox using the DataGridTemplateColumn, the problem is I'm not sure how the Binding would work when using a TextBox?
ListOne contains code and description which is bound and displays correctly. My SQL Stored Procedure returns extra values using a Join, which I'd like to display as editable fields ListOne.
Any ideas?
You should probably try to bind the DataGrid directly to the joined data as i imagine that doing joins directly in the cells may be difficult and round-about.

Binding const array to a grid in Silverlight

I'm new to Silverlight, so this might be a simple question to answer. I have a grid (not DataGrid from the toolkit), so that data displayed in it can be easily tabulated. I want to bind the grid to a string array that never changes, hence the number of rows and columns in the grid will not change either. I see that I cannot specify a template like I can for a ListBox (ListBox.ItemTemplate) and I don't want to define each row and column explicitly (with a TextBlock in each one of them) in XAML. And I also dont want to generate rows and columns dynamically in code behind as it is not blendable. What's the best way to do this?
You might like this post

Datagridview cell forecolor question (winform)

I have a requirement to display a text in various colors within a datagridview cell.
I mean, within one same cell, I need to use several colors !
Which color is to be applied depends on the value of each character.
Any clue? Is there any other object than the datagridview (like a sort of table for instance)
If I could use several Labels within the cell, it would do the job, but how?
AFAIK you should derive your own label class from label and handle the drawing yourself.
Another approach would be handling the datagridview data binding event and creating as many labels as you need for your cell.
I would go with deriving in this case, since the implementation would consist mostly of pretty basic GDI+ stuff and is more flexible than always creating multiple labels.

WPF DataGrid - Setting RowDetails programmatically

I'm using the WPF DataGrid, and I'd like to know if there is any way I can access the DataGridRow's RowDetails programatically.
For example, when the user selects the row, I'd to grab some data from somewhere (say, a database), and display it in the RowDetails.
All of the examples I've seen tend to just display some extra bound data that isn't included in the columns for the row.
You could display some extra data but lazy-load it on SelectionChanged.
It usually is not easy to work directly with the WPF controls, they are not really meant to be used without a backing databound model.
If you have all the data in list of objects (or something similar) then you can do all sorts of fun things. I'm using a WPF Datagrid in this manner, and when a user selects a row, I think populate an editor control above the grid with the row item plus additional details.
That said, there's nothing stopping you from adding in additional information in the grid that's normally hidden and a trigger on row selection to show the additional data
you can use the following code
DataRowView row = (DataRowView)MyDataGrid.SelectedItem;
string strName = row.Row["Name"].ToString(); //where "Name" is the column name

Resources