This question is locked. New answers and comments are not allowed.
I have two questions about binding on RadGridViewColumn.
I created a simple grid and use a array of data (a clasic CLR class... not dynamic) as itemsource.
I use the converter to display Debug Information.
My data (as items source is) :
When I execute, I got :
[Converter] Value : teststaticurl.html / TargetType : Object
[Converter] Value : teststaticurl.html / TargetType : ImageSource
[Converter] Value : TestStatic / TargetType : Object
My first question is : Why two calls are made to the converter for the GridViewImageColumns ? (one with Object as targetType and the other with ImageSource)
Then I try to use the samedatagrid with an object derived from DynamicObject :
When I execute, I got :
[Converter] Value : testdynurl.html / TargetType : Object
System.Windows.Data Error: BindingExpression path error: 'ImageUrl' property not found on 'RadGridViewTest.ModelDynamic' 'RadGridViewTest.ModelDynamic' (HashCode=60620523). BindingExpression: Path='ImageUrl' DataItem='RadGridViewTest.ModelDynamic' (HashCode=60620523); target element is 'System.Windows.Controls.Image' (Name=''); target property is 'Source' (type 'System.Windows.Media.ImageSource')..
[Converter] Value : TestDynamic / TargetType : Object
The data for the GridViewDataColumn work correctly, but I don't understand why the second call to the converter for the GridViewImageColumn failed saying it couldn't found the property... property it has found before by calling the converter the first time with the correct value.
Sorry if the question is not really clear (not very simple to explain in word). I upload a sample project to reproduce the problem on my Skydrive : RadGridViewDynamicBug
Thanks in advance for your answer.
Note : I use version 2011.2.712.1040
I created a simple grid and use a array of data (a clasic CLR class... not dynamic) as itemsource.
<telerik:RadGridView AutoGenerateColumns="False" x:Name="datagrid" >
<telerik:RadGridView.Columns>
<telerik:GridViewImageColumn DataMemberBinding="{Binding ImageUrl,Converter={StaticResource convert}}" Header="Image" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Title,Converter={StaticResource convert}}" Header="Titre" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
I use the converter to display Debug Information.
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Debug.WriteLine(string.Format("[Converter] Value : {0} / TargetType : {1}", value, targetType.Name));
return value;
}
My data (as items source is) :
Model[] vals = new Model[] {
new Model() { Title = "TestStatic", ImageUrl = "teststaticurl.html" },
};
When I execute, I got :
[Converter] Value : teststaticurl.html / TargetType : Object
[Converter] Value : teststaticurl.html / TargetType : ImageSource
[Converter] Value : TestStatic / TargetType : Object
My first question is : Why two calls are made to the converter for the GridViewImageColumns ? (one with Object as targetType and the other with ImageSource)
Then I try to use the samedatagrid with an object derived from DynamicObject :
public class ModelDynamic : DynamicObject
{
public override System.Collections.Generic.IEnumerable<string> GetDynamicMemberNames()
{
return new string[] { "Title", "ImageUrl" };
}
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
string name = binder.Name;
result = "";
if (name == "Title")
result = "TestDynamic";
else if (name == "ImageUrl")
result = "testdynurl.html";
return true;
}
}
When I execute, I got :
[Converter] Value : testdynurl.html / TargetType : Object
System.Windows.Data Error: BindingExpression path error: 'ImageUrl' property not found on 'RadGridViewTest.ModelDynamic' 'RadGridViewTest.ModelDynamic' (HashCode=60620523). BindingExpression: Path='ImageUrl' DataItem='RadGridViewTest.ModelDynamic' (HashCode=60620523); target element is 'System.Windows.Controls.Image' (Name=''); target property is 'Source' (type 'System.Windows.Media.ImageSource')..
[Converter] Value : TestDynamic / TargetType : Object
The data for the GridViewDataColumn work correctly, but I don't understand why the second call to the converter for the GridViewImageColumn failed saying it couldn't found the property... property it has found before by calling the converter the first time with the correct value.
Sorry if the question is not really clear (not very simple to explain in word). I upload a sample project to reproduce the problem on my Skydrive : RadGridViewDynamicBug
Thanks in advance for your answer.
Note : I use version 2011.2.712.1040
