I've some problem to manage one binding.
Here is my case:
I've a RadGridView, which basically allows me to sort/search/filter a datacollection, and then details are displayed and editable on the right of the radGridview.
One column is a GridViewImageColumn. This image represent the "status" of the element of the current row.
Here is my binding:
DataMemberBinding=
"{Binding Converter={StaticResource MyRowToImageConverter}}"
To display the content of this column, I need a converter, which takes the whole current row, analyze it and give the correct image.
This choice is made on several fields(Enums, ObservableCollections, ...)
The converter is working good and display the correct icon, the problem, is that when something change(the most typical case is the ObservableCollection, which get a new element), the binding isn't aware of this change.
So I don't see how to update this fields:
-I don't think it's possible to have a Multiple data binding in the radGridView(if yes, I can bind every fields I use for the calculation, and then, when one change, I receive the change event and then the binding is automatically updated)
-In the code behind I get informed when I should update thoses fields, but I've no idea about how to ask to refresh one(or all) binding of the current row
So how can I do this??
Thank you for your help
9 Answers, 1 is accepted
I have prepared a very simple project that illustrates a possible approach to this scenario, utilizing INotifyPropertyChanged. I am attaching it for your reference.
Regards,
Ivan Ivanov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
There is an huge difference between your example and mine, I cannot bind a property of the current object, but the full object, because the converter is using several fields of my object.
All my objects have already the INotifyPropertyChanged. And all other column are already automatically updated,
RadGridView has two ways of refreshing the UI after changes in data.
1. INotifyPropertyChanged
2. Calling the Rebind() method.
Since INotifyPropertyChanged is usable only when you bind to a property ( not the entire object) , we remain only with the second option - call the Rebind method of RadGridView after a change in the data was made.
Regards,
Pavel Pavlov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
The whole table.
All the best,
Pavel Pavlov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
What about filter values?. I mean, your example is perfect for my because I'm trying to change the ugly text displayed in the filter control.
I want to show "decreasing", "increasing" or "unchanged" instead of "images\increasing.png".
How can I change these values displayed in the filter control?
Thank you very much
Oscar
For the very next service pack - planned for 24 th of July RadGridView will have some improvements in this context - filtering control for image columns will show the images , rather than their text representation.
Would that work for you?
All the best,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
That's perfect and more logical behavior then before. Thank you very much.
I guess that if I want to show texts rather than their images, I would have to build a custom filter control. Right?
Anyway the new features will go to me much better than now.
Best regards,
Oscar
I have some updates on the issue. I have talked to the guys responsible for filtering. It appears there is some uncertainty about the feature. They are not sure whether it is going to be included in the service pack as they are experiencing some design and appearance problems with differently sized images and similar marginal cases.
Therefore I think I owe you an alternative solution :
public
class
ImageFilterColumn : GridViewImageColumn
{
/// <summary>
/// Gets the filtering display function.
/// </summary>
/// <value>The filtering display function.</value>
/// <remarks>This function is used by the filtering control distinct values list.
/// It accepts a raw data value and returns what will become the content of the
/// distinct value checkbox.</remarks>
protected
override
Func<
object
,
object
> FilteringDisplayFunc
{
get
{
return
ImageFilterColumn.ConvertUriStringToImage; }
}
public
static
object
ConvertUriStringToImage(
object
uriString)
{
var image =
new
Image();
image.Source =
new
BitmapImage(
new
Uri(uriString.ToString(), UriKind.Relative));
return
image;
}
}
Use the ImageFilterColumn from above , instead of the Regular image column. Actually you can modify the Func above to return your own modified text, image or whatever you need.
e.g.
protected
override
Func<
object
,
object
> FilteringDisplayFunc
{
get
{
return
"My custom text";
}
}
Let me know in case you need the above code integrated in a working example .
Regards,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>