Have following code:
public interface ITest
{
string St1 { get; }
}
public class Test:ITest
{
public string St1 { get { return "Interface Property"; } }
public string St2 { get { return "Descedent Property"; } }
}
public partial class MainWindow : Window
{
public ObservableCollection<ITest> TestColl = new ObservableCollection<ITest>();
public MainWindow()
{
TestColl.Add(new Test());
TestColl.Add(new Test());
InitializeComponent();
gridControl1.DataSource = TestColl;
}
}
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="382" Width="600" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
<Grid>
<dxg:GridControl HorizontalAlignment="Left" Name="gridControl1" VerticalAlignment="Top" Height="262">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="St1" />
<dxg:GridColumn FieldName="St2" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView Name="tableView1" />
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>
So everything is ok with St1, but St2 is not displayed. I guess because grid do not determine real run-time type, and use type declared in collection. Is there a way to make this sample work? Standart WPF DataGrid resolve property names correctlly.
We have answered your question in our forum at:
Map FieldName to descenendent object’s property