This topic provides information on how to style shapes of geographic series in the XamGeographicMap™ control.
The following table lists the topics required as a prerequisite to understanding this topic.
This topic contains the following sections:
In the XamGeographicMap control, shapes are visual elements that represent polygons or polylines in a geographic context. These shapes are defined by a data column mapped to the ShapeMemberPath property of geographic series.
The following types of geographic series support shapes:
The following table summarized properties for styling shape elements in geographic series:
The following table lists the code examples included in this topic.
The TargetType property of a Style applied to the ShapeStyle[ShapeStyle] property must match the type of shape elements used by geographic series.
The following table maps the types geographic series to expected types of shape elements:
The following is a preview of the XamGeographicMap with a style applied to shape elements of geographic series.
In XAML:
<ig:XamGeographicMap x:Name="GeoMap">
<ig:XamGeographicMap.Series>
<ig:GeographicShapeSeries x:Name="geoSeries" >
<ig:GeographicShapeSeries.ShapeStyle>
<Style TargetType="Path">
<Setter Property="Fill" Value="#E2444748" />
<Setter Property="Stroke" Value="#B1B0B7BA" />
<Setter Property="StrokeThickness" Value="1" />
</Style>
</ig:GeographicShapeSeries.ShapeStyle>
</ig:GeographicShapeSeries>
</ig:XamGeographicMap.Series>
</ig:XamGeographicMap>
In Visual Basic:
Dim style = New Style(GetType(Path))
style.Setters.Add(new Setter(Path.FillProperty, "#E2444748"))
style.Setters.Add(new Setter(Path.StrokeProperty, "#B1B0B7BA"))
style.Setters.Add(new Setter(Path.StrokeThicknessProperty, 1))
Dim geoSeries = New GeographicShapeSeries()
geoSeries.ShapeStyle = style
Me.GeoMap.Series.Add(geoSeries)
In C#:
var style = new Style(typeof(Path));
style.Setters.Add(new Setter(Path.FillProperty, "#E2444748"));
style.Setters.Add(new Setter(Path.StrokeProperty, "#B1B0B7BA"));
style.Setters.Add(new Setter(Path.StrokeThicknessProperty, 1));
var geoSeries = new GeographicShapeSeries();
geoSeries.ShapeStyle = style;
this.GeoMap.Series.Add(geoSeries);
The following table summarizes types of style selector that can be applied to the ShapeStyleSelector property of a geographic series.
The following is a preview of the XamGeographicMap with conditional styling of shape elements of geographic series.
The following code applies the ConditionalStyleSelector with conditional rules for rendering shape elements based on values of data items bound to the ItemsSource property of the GeographicShapeSeries.
In XAML:
<ig:XamGeographicMap x:Name="GeoMap">
<ig:XamGeographicMap.Resources>
<Style TargetType="Path" x:Key="shapeAsiaStyle">
<Setter Property="Fill" Value="#FF5F3E9D" />
<Setter Property="Stroke" Value="White" />
</Style>
<Style TargetType="Path" x:Key="shapeEuropeStyle">
<Setter Property="Fill" Value="#FFBF3D3D" />
<Setter Property="Stroke" Value="White" />
</Style>
<Style TargetType="Path" x:Key="shapeAfricaStyle">
<Setter Property="Fill" Value="#FF3B7F2A" />
<Setter Property="Stroke" Value="White" />
</Style>
<Style TargetType="Path" x:Key="shapeNorthAmericaStyle">
<Setter Property="Fill" Value="#FF3D5DAF" />
<Setter Property="Stroke" Value="White" />
</Style>
<Style TargetType="Path" x:Key="shapeLatinAmericaStyle">
<Setter Property="Fill" Value="#FF5B5D61" />
<Setter Property="Stroke" Value="White" />
</Style>
<Style TargetType="Path" x:Key="shapeAustraliaStyle">
<Setter Property="Fill" Value="#FFC6B046" />
<Setter Property="Stroke" Value="White" />
</Style>
</ig:XamGeographicMap.Resources>
<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="Europe" StyleToApply="{StaticResource shapeEuropeStyle}" />
<ig:EqualToConditionalStyleRule ValueMemberPath="Fields[REGION]" ComparisonValue="Africa" StyleToApply="{StaticResource shapeAfricaStyle}" />
<ig:EqualToConditionalStyleRule ValueMemberPath="Fields[REGION]" ComparisonValue="North America" StyleToApply="{StaticResource shapeNorthAmericaStyle}" />
<ig:EqualToConditionalStyleRule ValueMemberPath="Fields[REGION]" ComparisonValue="Latin America" StyleToApply="{StaticResource shapeLatinAmericaStyle}" />
<ig:EqualToConditionalStyleRule ValueMemberPath="Fields[REGION]" ComparisonValue="Australia" StyleToApply="{StaticResource shapeAustraliaStyle}" />
</ig:ConditionalStyleSelector.Rules>
</ig:ConditionalStyleSelector>
</ig:GeographicShapeSeries.ShapeStyleSelector>
</ig:GeographicShapeSeries>
</ig:XamGeographicMap.Series>
</ig:XamGeographicMap>
In Visual Basic:
Dim shapeAsiaStyle = New Style(typeof(Path))
style.Setters.Add(New Setter(Path.FillProperty, "#FF5F3E9D"))
style.Setters.Add(New Setter(Path.StrokeProperty, "White"))
Dim shapeEuropeStyle = New Style(typeof(Path))
style.Setters.Add(New Setter(Path.FillProperty, "#FFBF3D3D"))
style.Setters.Add(New Setter(Path.StrokeProperty, "White"))
Dim shapeAfricaStyle = New Style(typeof(Path))
style.Setters.Add(New Setter(Path.FillProperty, "#FF3B7F2A"))
style.Setters.Add(New Setter(Path.StrokeProperty, "White"))
Dim shapeNorthAmericaStyle = New Style(typeof(Path))
style.Setters.Add(New Setter(Path.FillProperty, "#FF3D5DAF"))
style.Setters.Add(New Setter(Path.StrokeProperty, "White"))
Dim shapeLatinAmericaStyle = New Style(typeof(Path))
style.Setters.Add(New Setter(Path.FillProperty, "#FFC6B046"))
style.Setters.Add(New Setter(Path.StrokeProperty, "White"))
Dim shapeAustraliaStyle = New Style(typeof(Path))
style.Setters.Add(New Setter(Path.FillProperty, "#FFC6B046"))
style.Setters.Add(New Setter(Path.StrokeProperty, "White"))
Dim selector = New ConditionalStyleSelector()
selector.Rules.Add(New EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Asia", StyleToApply = shapeAsiaStyle } )
selector.Rules.Add(New EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Europe", StyleToApply = shapeEuropeStyle });
selector.Rules.Add(New EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Africa", StyleToApply = shapeAfricaStyle })
selector.Rules.Add(New EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "North America", StyleToApply = shapeNorthAmericaStyle })
selector.Rules.Add(New EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Latin America", StyleToApply = shapeLatinAmericaStyle })
selector.Rules.Add(New EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Australia", StyleToApply = shapeAustraliaStyle })
var geoSeries = New GeographicShapeSeries()
geoSeries.StyleSelector = selector
GeoMap.Series.Add(geoSeries)
In C#:
var shapeAsiaStyle = new Style(typeof(Path));
style.Setters.Add(new Setter(Path.FillProperty, "#FF5F3E9D"));
style.Setters.Add(new Setter(Path.StrokeProperty, "White"));
var shapeEuropeStyle = new Style(typeof(Path));
style.Setters.Add(new Setter(Path.FillProperty, "#FFBF3D3D"));
style.Setters.Add(new Setter(Path.StrokeProperty, "White"));
var shapeAfricaStyle = new Style(typeof(Path));
style.Setters.Add(new Setter(Path.FillProperty, "#FF3B7F2A"));
style.Setters.Add(new Setter(Path.StrokeProperty, "White"));
var shapeNorthAmericaStyle = new Style(typeof(Path));
style.Setters.Add(new Setter(Path.FillProperty, "#FF3D5DAF"));
style.Setters.Add(new Setter(Path.StrokeProperty, "White"));
var shapeLatinAmericaStyle = new Style(typeof(Path));
style.Setters.Add(new Setter(Path.FillProperty, "#FFC6B046"));
style.Setters.Add(new Setter(Path.StrokeProperty, "White"));
var shapeAustraliaStyle = new Style(typeof(Path));
style.Setters.Add(new Setter(Path.FillProperty, "#FFC6B046"));
style.Setters.Add(new Setter(Path.StrokeProperty, "White"));
var selector = new ConditionalStyleSelector();
selector.Rules.Add(new EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Asia", StyleToApply = shapeAsiaStyle } );
selector.Rules.Add(new EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Europe", StyleToApply = shapeEuropeStyle });
selector.Rules.Add(new EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Africa", StyleToApply = shapeAfricaStyle });
selector.Rules.Add(new EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "North America", StyleToApply = shapeNorthAmericaStyle });
selector.Rules.Add(new EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Latin America", StyleToApply = shapeLatinAmericaStyle });
selector.Rules.Add(new EqualToConditionalStyleRule { ValueMemberPath = "Fields[REGION]", ComparisonValue = "Australia", StyleToApply = shapeAustraliaStyle });
var geoSeries = new GeographicShapeSeries();
geoSeries.StyleSelector = selector;
GeoMap.Series.Add(geoSeries);
The following topics provide additional information related to this topic.