Back to Devexpress

DiagramItem.Background Property

wpf-devexpress-dot-xpf-dot-diagram-dot-diagramitem-f356e144.md

latest8.2 KB
Original Source

DiagramItem.Background Property

Gets or sets the brush used to paint the diagram item background.

Namespace : DevExpress.Xpf.Diagram

Assembly : DevExpress.Xpf.Diagram.v25.2.dll

NuGet Package : DevExpress.Wpf.Diagram

Declaration

csharp
[Browsable(false)]
public Brush Background { get; set; }
vb
<Browsable(False)>
Public Property Background As Brush

Property Value

TypeDescription
Brush

A Brush object, that specifies how the diagram item background is painted.

|

Remarks

Diagram themes are predefined sets of diagram item styles that can be applied to a diagram in a single click. Each theme consists of font settings and a set of styles that can be applied to individual diagram items. Styles are a combination of background, foreground and stroke colors used to paint an item.

The DevExpress.Diagram.Core.DiagramThemeColorId enumeration stores identifiers of theme colors. Use the BackgroundId property to get or set the theme color of the item’s background. The StrokeId property specifies the color of the item’s outline.

Use the Background property to paint the diagram item’s background with a custom brush.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Background property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-diagram-use-diagramdatabindingbehavior-to-generate-diagram-from-collection/CS/DiagramDataBindingBehavior/MainWindow.xaml#L16

xml
<dxdiag:DiagramControl CanvasSizeMode="Fill" SelectedStencils="TemplateDesigner" ShowPageBreaks="false">
    <dxdiag:DiagramContainer Anchors="Left, Top" Background="#FFCEE1F2" CanCopyWithoutParent="True" ConnectionPoints="0.5,0 1,0.5 0.5,1 0,0.5" CanAddItems="False" DragMode="ByAnyPoint" Height="78" ItemsCanChangeParent="False" ItemsCanAttachConnectorEndPoint="False" ItemsCanAttachConnectorBeginPoint="False" ItemsCanSelect="False" ItemsCanEdit="False" ItemsCanCopyWithoutParent="False" ItemsCanMove="False" ItemsCanRotate="False" ItemsCanSnapToOtherItems="False" ItemsCanDeleteWithoutParent="False" ItemsCanSnapToThisItem="False" ItemsCanResize="False" Position="25,150" StrokeId="Black" Shape="StandardContainers.Alternating" ShowHeader="False" StrokeDashArray="5 3" ThemeStyleId="ShapeId.Focused1" TemplateName="ClassShape" Width="200">
        <dxdiag:DiagramShape Anchors="Left, Top" Angle="0" Background="Transparent" CanAttachConnectorBeginPoint="False" CanResize="False" CanEdit="False" CanCopyWithoutParent="False" CanChangeParent="False" CanMove="False" CanAttachConnectorEndPoint="False" CanSelect="False" CanDeleteWithoutParent="False" CanRotate="False" ForegroundId="Black" FontWeight="Bold" FontFamily="Arial" Height="25" Position="11,10" StrokeThickness="0" ThemeStyleId="Variant2" TextAlignment="Left" Width="176">

wpf-diagramcontrol-create-items-with-custom-content/CS/DXDiagram.ContentItem/DiagramResources.xaml#L9

xml
<Style x:Key="formattedTextContentItem" TargetType="dxdiag:DiagramContentItem">
    <Setter Property="Background" Value="#FF35779C"/>
    <Setter Property="ContentTemplate">

wpf-generate-diagram-with-grouped-items/CS/DiagramNestedItemsExample/MainWindow.xaml#L57

xml
MinHeight="50"
Background="Green"
ConnectionPoints="0,0.5 1,0.5"

wpf-diagram-create-custom-shapes-based-on-diagram-containers/CS/WpfApp13/MainWindow.xaml.cs#L32

csharp
container.StrokeThickness = 0;
container.Background = Brushes.Transparent;

wpf-generate-diagram-with-grouped-items/CS/DiagramNestedItemsExample/MainWindow.xaml.cs#L16

csharp
e.Item.SetBinding(DiagramShape.ContentProperty, new Binding("EmployeeName"));
e.Item.Background = Brushes.Orange;
i++;

wpf-diagram-create-custom-shapes-based-on-diagram-containers/VB/WpfApp13/MainWindow.xaml.vb#L27

vb
container.StrokeThickness = 0
container.Background = Brushes.Transparent
Dim innerShape1 = New DiagramShape() With {.CanSelect = False, .CanChangeParent = False, .CanEdit = False, .CanCopyWithoutParent = False, .CanDeleteWithoutParent = False, .CanMove = False, .Shape = BasicShapes.Trapezoid, .Anchors = Sides.Top Or Sides.Left Or Sides.Right, .Height = 50, .Width = 200, .Content = "Custom text"}

wpf-diagram-proportionally-resize-shapes-within-container/VB/WpfApp13/MainWindow.xaml.vb#L52

vb
container.StrokeThickness = 0
container.Background = Brushes.Transparent
Dim innerShape1 = New DiagramShape() With {.CanSelect = True, .CanChangeParent = False, .CanEdit = True, .CanResize = False, .CanCopyWithoutParent = False, .CanDeleteWithoutParent = False, .CanMove = False, .Shape = BasicShapes.Trapezoid, .Height = 50, .Width = 200, .Content = "Custom text"}

wpf-diagram-create-rotatable-containers-with-shapes/VB/WpfApp13/MainWindow.xaml.vb#L60

vb
container.StrokeThickness = 0
container.Background = Brushes.Transparent
Dim innerShape1 = New DiagramShape() With {.CanSelect = True, .CanChangeParent = False, .CanEdit = True, .CanResize = False, .CanRotate = False, .CanCopyWithoutParent = False, .CanDeleteWithoutParent = False, .CanMove = False, .Shape = BasicShapes.Trapezoid, .Height = 50, .Width = 200, .Content = "Custom text"}

wpf-generate-diagram-with-grouped-items/VB/DiagramNestedItemsExample/MainWindow.xaml.vb#L21

vb
e.Item.SetBinding(DiagramShape.ContentProperty, New Binding("EmployeeName"))
e.Item.Background = Brushes.Orange
i += 1

See Also

Stroke

Foreground

DiagramItem Class

DiagramItem Members

DevExpress.Xpf.Diagram Namespace