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
95
Setting colours of countries
posted

Hi,

I am looking to bind the colours of specific countries to properties in a view model (e.g. country of departure and country of arrival). Information loaded via shapefiles and a converter into a GeographicShapeControlSeries. All examples i've seen either use random colours, or some sort of gradient based on a property of the map source, such as temperature.

For my case, I applied a style based on the Geographic Shape Control Series example from the sample browser, which exposes the RootElement Path, i have added the country name to the tag of this element. Currently the only approach i have found to work is to subscribe to the loaded event of this Path and check in code-behind if the tag is either the desired departure or arrival country names. This isn't ideal; i've been running into difficulty exposing the collection of countries so i can bind the Fill Dependency Property to a Brush object in the ViewModel. The closest i came was a UIElementCollection of the Canvas, but could not get any further.

It feels like i'm missing something obvious to achieve my goal of binding specific country colours, possibly something to do with Shape Style Selectors? Any advice on how to proceed would be greatly appreciated.

Thanks.

Parents
  • 138253
    Verified Answer
    Offline posted

    Hello Frazer,

    Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I set the XamGeographicMap’s ShapeStyleSelector to be a ConditionalStyleSelector. This way I was able to apply different Styles based on a Field’s Value(in my case Code). Please let me know if this helps you or you have further questions on this matter.

    Looking forward for your reply.

    XamGeographicMapColorsSample.zip
Reply Children