Back to Devexpress

ToggleSwitch.UndefinedStateContent Property

wpf-devexpress-dot-xpf-dot-editors-dot-toggleswitch-40af8c0b.md

latest4.5 KB
Original Source

ToggleSwitch.UndefinedStateContent Property

Gets or sets the content that is displayed when the toggle switch is in the undefined state. This is a dependency property.

Namespace : DevExpress.Xpf.Editors

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public object UndefinedStateContent { get; set; }
vb
Public Property UndefinedStateContent As Object

Property Value

TypeDescription
Object

The content of the toggle switch.

|

Remarks

The ToggleSwitch displays the UndefinedStateContent only when the IsThreeState is true.

The following code sample specifies the UndefinedStateContent , CornerRadius, EditorAppearanceProperties.FocusedBorderBrush, EditorAppearanceProperties.CheckedStateBackground, and EditorAppearanceProperties.CheckedStateBorderBrush properties.

xaml
<Window ...
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">
    <StackPanel>
        <dxe:ToggleSwitch Margin="5" BorderThickness="2" BorderBrush="#FF757575" 
                          Background="White" CornerRadius="10"
                          ToggleSwitchHeight="20" ToggleSwitchWidth="45"
                          HorizontalAlignment="Left" ContentPlacement="Far"
                          CheckedStateContent="On" UncheckedState Content="Off"
                          IsThreeState="True" UndefinedStateContent="Null"
                          dxe:EditorAppearanceProperties.FocusedBorderBrush="#FF6200EE"
                          dxe:EditorAppearanceProperties.CheckedStateBackground="#FF6200EE"
                          dxe:EditorAppearanceProperties.CheckedStateBorderBrush="#FF6200EE">>
            <dxe:ToggleSwitch.SwitchThumbTemplate>
                <DataTemplate>
                    <Grid>
                        <Ellipse Width="12" Height="12" Margin="5,4" Fill="#FF757575" x:Name="ellipse" />
                    </Grid>
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=IsChecked, RelativeSource={RelativeSource AncestorType=dxe:ToggleSwitch}}"
                                                 Value="True">
                            <Setter Property="Fill"
                                                TargetName="ellipse" Value="PaleGoldenrod" />
                        </DataTrigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </dxe:ToggleSwitch.SwitchThumbTemplate>
        </dxe:ToggleSwitch>
    </StackPanel>
</Window>

Note

The property is supported in the following DevExpress themes:

Theme FamilyThemes
Windows 11Dark, Light
Windows 10Dark, Light
Office 2019Black, Colorful, Dark Gray, White, HighContrast
Visual Studio 2019Blue, Dark, Light
Office 2016 SEBlack, Colorful, Dark Gray, White
Visual Studio 2017Blue, Dark, Light

See Also

ToggleSwitch Class

ToggleSwitch Members

DevExpress.Xpf.Editors Namespace