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
30
How to make GeographicShapeSeries.ShapeStyleSelector dynamic?
posted

The following code applies the ConditionalStyleSelector to the GeographicShapeSeries:

<ig:XamGeographicMap.Series>
    <ig:GeographicShapeSeries 
        ItemsSource="{StaticResource shapeFileSource}"
        ShapeMemberPath="Points">
        <ig:GeographicShapeSeries.ShapeStyleSelector>
            <ig:ConditionalStyleSelector>
                <ig:ConditionalStyleSelector.Rules>
                    <ig:EqualToConditionalStyleRule ValueMemberPath="Fields[REGION]" ComparisonValue="Asia" StyleToApply="{StaticResource shapeAsiaStyle}" />
                    <ig:EqualToConditionalStyleRule ValueMemberPath="Fields[REGION]" ComparisonValue="Australia" StyleToApply="{StaticResource shapeAustraliaStyle}" />
                </ig:ConditionalStyleSelector.Rules>
            </ig:ConditionalStyleSelector>
        </ig:GeographicShapeSeries.ShapeStyleSelector>
    </ig:GeographicShapeSeries>
</ig:XamGeographicMap.Series>

Now my question is that How can I make these conditional rules dynamic, let's say I have an ObservableCollection of ConditionalStyleRule:

public class MyViewModel
{
    public ObservableCollection<ConditionalStyleRule> Rules { get; set; }

    //....
}

Now how can I bind these collection to view, I mean Is it possible to have something like this:

<ig:GeographicShapeSeries.ShapeStyleSelector>
    <ig:ConditionalStyleSelector>
        <ig:ConditionalStyleSelector.Rules DataContext="{Binding Rules}">
        </ig:ConditionalStyleSelector.Rules>
    </ig:ConditionalStyleSelector>
</ig:GeographicShapeSeries.ShapeStyleSelector>