开发者

Binding to DomainDataSource with DataGrid in Silverlight 3

开发者 https://www.devze.com 2022-12-16 07:23 出处:网络
Using markup I can\'t get data to show in the grid: <riacontrols:DomainDataSource x:Name=\"EstimatesData\"QueryName=\"GetUserEstimates\" >

Using markup I can't get data to show in the grid:

<riacontrols:DomainDataSource x:Name="EstimatesData"  QueryName="GetUserEstimates" >
    <riacontrols:Doma开发者_C百科inDataSource.DataContext>
        <ds:MyDomainContext  /> 
    </riacontrols:DomainDataSource.DataContext>
</riacontrols:DomainDataSource>
<datagrid:DataGrid x:Name="EstimatesGrid" ItemsSource="{Binding ElementName=EstimatesData, Path=Data}" />

MyDomainContext has a model UserEstimates with a method GetUserEstimatesQuery.

When the page loads, the breakpoint in GetUserEstimatesQuery does not get hit, the method is not called. There are no errors, what am I missing?

If I write code behind on the page load, it binds OK.


I had the same problem. I've solved it by changing:

<riacontrols:DomainDataSource.DataContext>

to

<riacontrols:DomainDataSource.DomainContext>


Forgot to mention the model came from a SQL View. I tried the same approach using a table and it worked fine. The problem was that there was no proper key defined on the model for the view, it had set about 6 fields as the key which would still not give a unique value.

End solution was to add a field to the view to use as the key, re-create the model, set the primary key field, and now data is displaying as expected now.


You need to do some debugging of your DomainDataSource usage to see if it's invoking the load at all. Try handling the LoadingData event and the LoadedData event to see what's going on.

This might have some more info that is helpful here: http://jeffhandley.com/archive/2009/11/19/domaindatasource-error-handling-again.aspx

You can also try to call the estimatesData.Load() in your code-behind to see if that helps troubleshoot your issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消