BarStaticItem Class
Represents a bar item that allows you to display static text.
Namespace: DevExpress.Xpf.Bars
Assembly:
DevExpress.Xpf.Core.v22.2.dll
NuGet Package:
DevExpress.Wpf.Core
Declaration
public class BarStaticItem :
BarItem
Public Class BarStaticItem
Inherits BarItem
Use a BarStaticItem object to display static text in bars and menus.

You can customize the auto-size mode for BarStaticItem items via the BarStaticItem.AutoSizeMode property. Setting this property to Fill stretches the item’s links, so that they occupy the largest possible area of a bar.
Example
This example shows how to create BarStaticItem items, used to display static text within bars.
The following image shows the result:

View Example
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Namespace BarStaticItemEx
''' <summary>
''' Interaction logic for Window1.xaml
''' </summary>
Partial Public Class Window1
Inherits Window
Public Sub New()
InitializeComponent()
AddHandler rtfEditor.SelectionChanged, AddressOf rtfEditor_SelectionChanged
End Sub
Private Sub rtfEditor_SelectionChanged(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim line As Integer = 0
Dim col As Integer = 0
rtfEditor.CaretPosition.GetLineStartPosition(-100000, line)
col = rtfEditor.CaretPosition.GetOffsetToPosition(rtfEditor.CaretPosition.GetLineStartPosition(0))
staticItemLine.Content = "Line: " & (-line).ToString() & " Position: " & (-col).ToString()
End Sub
End Class
End Namespace
<Application x:Class="BarStaticItemEx.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml" Startup="OnAppStartup_UpdateThemeName">
<Application.Resources>
</Application.Resources>
</Application>
Imports System
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Windows
Namespace BarStaticItemEx
''' <summary>
''' Interaction logic for App.xaml
''' </summary>
Partial Public Class App
Inherits Application
Private Sub OnAppStartup_UpdateThemeName(ByVal sender As Object, ByVal e As StartupEventArgs)
DevExpress.Xpf.Core.ApplicationThemeHelper.UpdateApplicationThemeName()
End Sub
End Class
End Namespace
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" x:Class="BarStaticItemEx.Window1" Title="Window1" Height="163.158" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<dxb:BarContainerControl Grid.Row="0">
<dxb:ToolBarControl>
<dxb:BarButtonItem x:Name="itemCopy" Content="Copy" Glyph="{dx:DXImage Image=Copy_16x16.png}" />
<dxb:BarButtonItem x:Name="itemPaste" Content="Paste" Glyph="{dx:DXImage Image=Paste_16x16.png}" />
<dxb:BarButtonItem x:Name="itemUndo" Content="Undo" Glyph="{dx:DXImage Image=Undo_16x16.png}" />
<dxb:BarButtonItem x:Name="itemRedo" Content="Redo" Glyph="{dx:DXImage Image=Redo_16x16.png}" />
</dxb:ToolBarControl>
</dxb:BarContainerControl>
<RichTextBox Grid.Row="1" x:Name="rtfEditor" />
<dxb:StatusBarControl Grid.Row="2">
<dxb:BarStaticItem x:Name="staticItemDocName" Content="Document Name: " AutoSizeMode="Fill" />
<dxb:BarStaticItem x:Name="staticItemLine" Content="Line: " />
</dxb:StatusBarControl>
</Grid>
</Window>
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;
namespace BarStaticItemEx {
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window {
public Window1() {
InitializeComponent();
rtfEditor.SelectionChanged += new RoutedEventHandler(rtfEditor_SelectionChanged);
}
void rtfEditor_SelectionChanged(object sender, RoutedEventArgs e) {
int line = 0;
int col = 0;
rtfEditor.CaretPosition.GetLineStartPosition(-100000, out line);
col = rtfEditor.CaretPosition.GetOffsetToPosition(rtfEditor.CaretPosition.GetLineStartPosition(0));
staticItemLine.Content = "Line: " + (-line).ToString() + " Position: " + (-col).ToString();
}
}
}
The following code snippets (auto-collected from DevExpress Examples) contain references to the BarStaticItem class.
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.
See Also