(If I change the color to "Transparent", the rectangles do become visible.)

I also tried using a

ControlTemplate

for the

UserControl

(as part of a

Style

), but I got the same results (i.e. the background color blocking the content of the UserControl).

I looked up the Control.Background property on MSDN which provides the following remarks:

The Background property applies only to the resting state of a
control. The default style of the control specifies its appearance
when the state of the control changes. For example, if you set the
Background property on a Button, the button has that value only when
it is not pressed or disabled. If you want to create a control that
has a more advanced customization of the background, you must define
the control's style.

This property only affects a control whose template uses the
Background property as a parameter. On other controls, this property
has no impact.

What is the significance of the remarks in MSDN, and how can I specify a background color without it blocking control content?

EDIT: The content control (the rectangles) are added manually in the codebehind, if that makes a difference.

UserControl code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

In order to write a custom control that does its rendering by means of an overridden OnRender method you should not derive from UserControl or even Control, as they draw themselves via a ControlTemplate, which also fills their area with the Background brush. All that is done outside their OnRender method, so overriding it and not calling the base class' OnRender won't help.

Instead, derive from FrameworkElement or UIElement, declare a Background property and fill the control area with the background before doing the rest of the rendering: