views:

57

answers:

1

So I'm working on a small project using the bing maps silverlight sdk. I'm getting a bunch of objects off a server (through wcf services) and each of these devices has a lat/long properties. To map something on bing maps, you supply it with a Location type (essentially just a wrapper for lat/long)

The types I'm working with are stored on the server and only have lat long. I wrote an extension method called Location that wraps them into a location and returns them.

       <DataTemplate x:Key="MapVisualDataTemplate">
        <m:Pushpin m:MapLayer.Position="{Binding Location}" />
    </DataTemplate>

Even though the extension method is visible and usable from within C#, it is not properly used by the xaml. If I add the property directly into the type on the server it works fine. Only by having it defined as an extension method it doesn't work. I'd rather have it be an extension method because it's eventually going to be used on a wide variety of types.

Is it possible to bind using the above syntax when Location is an extension method for whatever type is currently bound to?

+1  A: 

I believe the reason is that in xaml you must bind to either a property or a dependency property. An extension method is just that, a method. Even if the method mimics a property it still isn't quite the same thing.

brandon