Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3627
Binding in xaml versus code behind
posted

I have a xamlgrid nest down a few levels into a layout grid.

 If I set the DataSource of the xamlgrid in code (create the object and then set the source = obj.prop), the grid works. I can't get it to work through xaml, though. I compared my xaml to that in the feature browser, and it sure looks the same to me.

First I create the object containing the data:

 <Grid.Resources>

      <ObjectDataProvider x:Key="SCRUB" ObjectType="{x:Type data:ScrubData}" />

</Grid.Resources>

Next I assign that object to the xamlgrid:

DataSource="{Binding Source={StaticResource SCRUB}, Path=GetTestData}"

GetTestDate() is the method name that returns the .

Meanwhile this code in the code-behind works:

this.XamDataGridObject.DataSource = App.ScrubData.GetTestData();

Now... data:ScrubData lives in another assembly and is referenced in the xaml as follows:

xmlns:data="clr-namespace:MyNamespace.Data;assembly=MyDll"

ps: this editor drives me nuts.

Can you spot anything missing? Thanks.