Skip to content

AreaStyle Guide

Namespace: ThinkGeo.Core
Applies to: All ThinkGeo products (WPF, WinForms, Blazor, MAUI, GIS Server, etc.)


Overview

AreaStyle controls how polygon features — parks, counties, land parcels, grid cells, buffers, and any other closed-ring geometry — are drawn on the map. It lets you set the fill color or brush, the outline pen, dash style, pixel offsets, and hatch patterns. AreaStyle is used directly on ZoomLevel slots and inside ClassBreakStyle and ValueStyle containers.


Constructors

Empty constructor — set properties manually

var areaStyle = new AreaStyle();
areaStyle.FillBrush = new GeoSolidBrush(GeoColors.LightGreen);
areaStyle.OutlinePen = new GeoPen(GeoColors.DarkGreen, 2);

Use this form when you need to set DashStyle, XOffsetInPixel, YOffsetInPixel, or other properties that are not covered by the shorter constructors. Source: blazorHowDoI:Shared/LayerBuilder.cs.

Fill only

// Named brush constant
parksLayer.ZoomLevelSet.ZoomLevel10.DefaultAreaStyle =
    new AreaStyle(GeoBrushes.PastelGreen);

// GeoSolidBrush with a specific color
var areaStyle = new AreaStyle(new GeoSolidBrush(GeoColors.Orange));

Source: winformHowDoI:Samples/VectorDataStyling/RenderBasedOnScales.cs.

Outline + fill

var areaStyle = new AreaStyle(GeoPens.DimGray, GeoBrushes.PastelGreen);

Source: winformHowDoI:Samples/VectorDataStyling/RenderLabels.cs, wpfHowDoI:Samples/VectorDataStyling/Renderlabels.xaml.cs, mauiHowDoI:Samples/VectorDataStyling/CreateTextStyle.xaml.cs.

Semi-transparent fill via GeoSolidBrush

// GeoColor.FromArgb(alpha, r, g, b)  — alpha 0 = fully transparent, 255 = fully opaque
var areaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 0, 255, 0)));

Source: wpfHowDoI:Samples/MapOfflineData/Raster/DisplayESRIGridFile.xaml.cs.

Outline + semi-transparent fill

var areaStyle = new AreaStyle(
    new GeoPen(GeoColors.Green, 3),
    new GeoSolidBrush(GeoColor.FromArgb(100, 0, 147, 221)));

Source: blazorHowDoI:Shared/GeometricFunctionHelper.cs.


Static Factory Methods

CreateSimpleAreaStyle

The quickest way to produce a solid-filled polygon with an outline. ThinkGeo samples use this method extensively.

// Opaque fill + outline
AreaStyle.CreateSimpleAreaStyle(GeoColors.Blue, GeoColors.Black);

// Semi-transparent fill + outline
AreaStyle.CreateSimpleAreaStyle(
    GeoColor.FromArgb(50, GeoColors.Green),
    GeoColors.Green);

// Semi-transparent fill + outline + explicit width
AreaStyle.CreateSimpleAreaStyle(
    GeoColor.FromArgb(50, GeoColors.Green),
    GeoColors.Green,
    2);

Source: winformHowDoI:Samples/VectorDataEditing/EditFeatures.cs, wpfHowDoI:Samples/VectorDataTopologicalValidation/ValidateLineTopology.xaml.cs.

CreateHatchStyle

Fills the polygon with a repeating hatch pattern. Full signature:

var areaStyle = AreaStyle.CreateHatchStyle(
    hatchStyle,          // GeoHatchStyle enum value
    GeoColors.Black,     // foreground / hatch line color
    GeoColors.Red,       // background color
    GeoColors.Blue,      // outline pen color
    5,                   // outline pen width
    LineDashStyle.Solid, // outline dash style
    0f,                  // x offset in pixels
    0f);                 // y offset in pixels

Populate a combo box from the full enum at startup, then re-style the layer on selection change:

foreach (GeoHatchStyle style in Enum.GetValues(typeof(GeoHatchStyle)))
{
    CboHatchStyles.Items.Add(style);
}
CboHatchStyles.SelectedItem = GeoHatchStyle.Cross; // default

Source: wpfHowDoI:Samples/VectorDataStyling/HatchStyles.xaml.cs.


Properties

The properties below are set directly on an AreaStyle instance and are the same ones the static factory methods configure internally. Source: blazorHowDoI:Shared/LayerBuilder.cs.

Property Type Description
FillBrush GeoBrush The brush used to fill the polygon interior. Typically a GeoSolidBrush.
OutlinePen GeoPen The pen used to draw the polygon border.
OutlinePen.DashStyle LineDashStyle Controls whether the outline is solid, dashed, dotted, etc.
XOffsetInPixel float Shifts the rendered shape horizontally by this many pixels.
YOffsetInPixel float Shifts the rendered shape vertically by this many pixels.
var areaStyle = new AreaStyle();
areaStyle.FillBrush = new GeoSolidBrush(fillBrushColor);
areaStyle.OutlinePen = new GeoPen(outlinePenColor, outlinePenWidth);
areaStyle.OutlinePen.DashStyle = LineDashStyle.Dash;
areaStyle.XOffsetInPixel = 0f;
areaStyle.YOffsetInPixel = 0f;

Attaching a Style to a Layer

DefaultAreaStyle — simple, single-style case

parksLayer.ZoomLevelSet.ZoomLevel10.DefaultAreaStyle =
    new AreaStyle(GeoBrushes.PastelGreen);
parksLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level14;

CustomStyles — when mixing style types on one zoom level

Use CustomStyles when a single zoom level needs both an AreaStyle and a TextStyle (or any other combination). Setting DefaultAreaStyle and DefaultTextStyle on the same zoom level is also valid, but CustomStyles gives you explicit ordering.

var areaStyle = new AreaStyle(GeoPens.DimGray, GeoBrushes.PastelGreen);
var textStyle = new TextStyle("NAME", new GeoFont("Segoe UI", 12, DrawingFontStyles.Bold), GeoBrushes.DarkGreen)
{
    FittingPolygon = true,
    HaloPen = new GeoPen(GeoBrushes.White, 2),
    DrawingLevel = DrawingLevel.LabelLevel,
    AllowLineCarriage = true,
    FittingPolygonInScreen = true
};

parksLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle);
parksLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle);
parksLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

Source: wpfHowDoI:Samples/VectorDataStyling/Renderlabels.xaml.cs.

Scale-dependent styling

Apply different levels of detail at different zoom ranges:

// Zoomed out (levels 10–14): fill only, no label
parksLayer.ZoomLevelSet.ZoomLevel10.DefaultAreaStyle =
    new AreaStyle(GeoBrushes.PastelGreen);
parksLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level14;

// Zoomed in (levels 15–20): fill + label
parksLayer.ZoomLevelSet.ZoomLevel15.DefaultAreaStyle =
    new AreaStyle(GeoBrushes.PastelGreen);
parksLayer.ZoomLevelSet.ZoomLevel15.DefaultTextStyle = new TextStyle(
    "NAME",
    new GeoFont("Segoe UI", 12, DrawingFontStyles.Bold),
    GeoBrushes.DarkGreen)
{
    FittingPolygon = false,
    HaloPen = new GeoPen(GeoBrushes.White, 2),
    DrawingLevel = DrawingLevel.LabelLevel,
    AllowLineCarriage = true,
    FittingPolygonFactor = 1
};
parksLayer.ZoomLevelSet.ZoomLevel15.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

Source: winformHowDoI:Samples/VectorDataStyling/RenderBasedOnScales.cs.


Using AreaStyle inside ClassBreakStyle

ClassBreakStyle assigns a different AreaStyle to features based on the numeric value of a column. This is the standard way to build choropleth maps or data-driven color ramps.

Grid / raster data (transparent sentinel + color ramp)

Use double.MinValue as the first break with a transparent fill so that features below the lowest threshold render as invisible rather than defaulting to a color.

var gridClassBreakStyle = new ClassBreakStyle("CellValue");
const byte alpha = 150;
gridClassBreakStyle.ClassBreaks.Add(
    new ClassBreak(double.MinValue, new AreaStyle(new GeoSolidBrush(GeoColors.Transparent))));
gridClassBreakStyle.ClassBreaks.Add(
    new ClassBreak(6.2, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(alpha, 255, 0, 0)))));
gridClassBreakStyle.ClassBreaks.Add(
    new ClassBreak(6.83, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(alpha, 255, 128, 0)))));
gridClassBreakStyle.ClassBreaks.Add(
    new ClassBreak(7.0, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(alpha, 245, 210, 10)))));
gridClassBreakStyle.ClassBreaks.Add(
    new ClassBreak(7.08, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(alpha, 225, 255, 0)))));
gridClassBreakStyle.ClassBreaks.Add(
    new ClassBreak(7.15, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(alpha, 224, 251, 132)))));
gridClassBreakStyle.ClassBreaks.Add(
    new ClassBreak(7.21, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(alpha, 128, 255, 128)))));
gridClassBreakStyle.ClassBreaks.Add(
    new ClassBreak(7.54, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(alpha, 0, 255, 0)))));

gridFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(gridClassBreakStyle);
gridFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

Source: wpfHowDoI:Samples/MapOfflineData/Vector/GenerateESRIGridFile.xaml.cs, winformHowDoI:Samples/MapOfflineData/Raster/DisplayESRIGridFile.cs, mauiHowDoI:Samples/MapOfflineData/ESRIGridLayer.xaml.cs.

Choropleth (dynamically computed color palette)

When colors are generated at runtime (for example from a ThinkGeo Cloud color service), build the ClassBreakStyle in a loop:

var classBreakStyle = new ClassBreakStyle();
classBreakStyle.ColumnName = "H_UNITS";
var classBreaksIntervals = new double[] { 0, 1000, 2000, 3000, 4000, 5000 };

for (var i = 0; i < colors.Count; i++)
{
    var areaStyle = new AreaStyle(new GeoSolidBrush(colors[colors.Count - i - 1]));
    classBreakStyle.ClassBreaks.Add(new ClassBreak(classBreaksIntervals[i], areaStyle));
}

housingUnitsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
housingUnitsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

Source: wpfHowDoI:Samples/ThinkGeoCloudIntegration/ColorUtilities.xaml.cs, winformHowDoI:Samples/ThinkGeoCloudIntegration/ColorUtilities.cs, mauiHowDoI:Samples/ThinkGeoCloudIntegration/ColorUtilitiesCloudServices.xaml.cs.


Using AreaStyle inside ValueStyle

ValueStyle maps discrete string column values to specific styles. AreaStyle instances are valid ValueItem style targets.

ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "Name";

// Default item (empty string) — catches any value not matched below
ValueItem defaultValueItem = new ValueItem();
defaultValueItem.Value = "";
defaultValueItem.CustomStyles.Add(
    new AreaStyle(new GeoPen(GeoColors.Green, 3),
                  new GeoSolidBrush(GeoColor.FromArgb(100, 0, 147, 221))));
valueStyle.ValueItems.Add(defaultValueItem);

// Named values map to specific fills
valueStyle.ValueItems.Add(new ValueItem("Buffering",
    new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(140, 255, 155, 13)))));

valueStyle.ValueItems.Add(new ValueItem("ClippingResult",
    new AreaStyle(new GeoPen(GeoColors.Black, 1),
                  new GeoSolidBrush(new GeoColor(160, 255, 248, 172)))));

valueStyle.ValueItems.Add(new ValueItem("SnappingBuffer",
    new AreaStyle(new GeoSolidBrush(GeoColors.Transparent))));

Source: blazorHowDoI:Shared/GeometricFunctionHelper.cs.


Common Patterns and Pitfalls

GeoColors.Transparent as a sentinel. When you need a feature to exist in the layer but render invisibly — for example as the catch-all double.MinValue break in a ClassBreakStyle, or for a SnappingBuffer in a ValueStyle — use new AreaStyle(new GeoSolidBrush(GeoColors.Transparent)) rather than removing the feature.

GeoColor vs GeoColors vs GeoBrushes. GeoColors is a static class of named GeoColor values. GeoBrushes is a static class of pre-built GeoSolidBrush objects. Use GeoColors.* when you need to pass a color to a constructor that takes GeoColor (such as GeoPen or GeoColor.FromArgb). Use GeoBrushes.* when passing directly to an AreaStyle or PointStyle constructor that accepts a GeoBrush.

// Correct — GeoPen takes GeoColor
new GeoPen(GeoColors.DimGray, 1)

// Correct — AreaStyle constructor overload takes GeoBrush
new AreaStyle(GeoBrushes.PastelGreen)

// Also correct — GeoSolidBrush wraps a GeoColor into a GeoBrush
new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 0, 255, 0)))

GeoPen accepts either GeoColor or GeoBrush. Both of these are valid:

new GeoPen(GeoColors.DimGray, 1)    // GeoColor overload
new GeoPen(GeoBrushes.DimGray, 1)   // GeoBrush overload — used in GeoPens.DimGray

Refreshing the map. Changing the style on a layer does not automatically redraw. After re-styling, call RefreshAsync on the relevant overlay:

StyleParksLayer(_currentHatchStyle);
await layerOverlay.RefreshAsync();

Source: wpfHowDoI:Samples/VectorDataStyling/HatchStyles.xaml.cs.


Source References

Sample Namespace AreaStyle usage
VectorDataStyling/RenderBasedOnScales WinForms, WPF new AreaStyle(GeoBrushes.PastelGreen) — fill-only, scale-dependent
VectorDataStyling/RenderLabels / Renderlabels WinForms, WPF, MAUI new AreaStyle(GeoPens.DimGray, GeoBrushes.PastelGreen) — outline + fill
VectorDataStyling/HatchStyles WPF AreaStyle.CreateHatchStyle(...) — full hatch signature
Shared/LayerBuilder.cs Blazor Property-by-property construction; FillBrush, OutlinePen, DashStyle, offsets
Shared/GeometricFunctionHelper.cs Blazor Constructor variants inside ValueStyle / ValueItem
MapOfflineData/GenerateESRIGridFile WPF, WinForms ClassBreakStyle + AreaStyle with transparent sentinel
MapOfflineData/DisplayESRIGridFile / ESRIGridLayer WPF, WinForms, MAUI ClassBreakStyle + AreaStyle color ramp
ThinkGeoCloudIntegration/ColorUtilities WPF, WinForms, MAUI Programmatic choropleth with ClassBreakStyle