Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

CustomStatePresentation Class

Contains presentation settings that specify the state appearance.

Namespace: DevExpress.Xpf.Gauges

Assembly: DevExpress.Xpf.Gauges.v24.2.dll

NuGet Package: DevExpress.Wpf.Gauges

#Declaration

public class CustomStatePresentation :
    StatePresentation

#Example

This example demonstrates how to define a custom state indicator’s state presentation.

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:GaugesDemoApp"
        xmlns:dxga="http://schemas.devexpress.com/winfx/2008/xaml/gauges" 
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        x:Class="GaugesDemoApp.MainWindow"
        Title="MainWindow" Height="350" Width="300">
    <Grid>
        <StackPanel Orientation="Vertical">
            <dxga:StateIndicatorControl Foreground="White" StateIndex="{Binding ElementName=tbeStateIndex, Path=Value}">
                <dxga:StateIndicatorControl.AdditionalStates>
                    <dxga:State>
                        <dxga:State.Presentation>
                            <dxga:CustomStatePresentation>
                                <dxga:CustomStatePresentation.StateTemplate>
                                    <ControlTemplate>
                                        <Viewbox>
                                            <Border Background="Black">
                                                <TextBlock Text="$"/>
                                            </Border>
                                        </Viewbox>
                                    </ControlTemplate>
                                </dxga:CustomStatePresentation.StateTemplate>
                            </dxga:CustomStatePresentation>
                        </dxga:State.Presentation>
                    </dxga:State>
                    <dxga:State>
                        <dxga:State.Presentation>
                            <dxga:CustomStatePresentation>
                                <dxga:CustomStatePresentation.StateTemplate>
                                    <ControlTemplate>
                                        <Viewbox>
                                            <Border Background="Black">
                                                <TextBlock Text="¥"/>
                                            </Border>
                                        </Viewbox>
                                    </ControlTemplate>
                                </dxga:CustomStatePresentation.StateTemplate>
                            </dxga:CustomStatePresentation>
                        </dxga:State.Presentation>
                    </dxga:State>
                    <dxga:State>
                        <dxga:State.Presentation>
                            <dxga:CustomStatePresentation>
                                <dxga:CustomStatePresentation.StateTemplate>
                                    <ControlTemplate>
                                        <Viewbox>
                                            <Border Background="Black">
                                                <TextBlock Text="£"/>
                                            </Border>
                                        </Viewbox>
                                    </ControlTemplate>
                                </dxga:CustomStatePresentation.StateTemplate>
                            </dxga:CustomStatePresentation>
                        </dxga:State.Presentation>
                    </dxga:State>
                    <dxga:State>
                        <dxga:State.Presentation>
                            <dxga:CustomStatePresentation>
                                <dxga:CustomStatePresentation.StateTemplate>
                                    <ControlTemplate>
                                        <Viewbox>
                                            <Border Background="Black">
                                                <TextBlock Text="€"/>
                                            </Border>
                                        </Viewbox>
                                    </ControlTemplate>
                                </dxga:CustomStatePresentation.StateTemplate>
                            </dxga:CustomStatePresentation>
                        </dxga:State.Presentation>
                    </dxga:State>
                </dxga:StateIndicatorControl.AdditionalStates>
            </dxga:StateIndicatorControl>
            <dxe:TrackBarEdit Minimum="0" Maximum="3" TickFrequency="1" Height="20" Width="100" x:Name="tbeStateIndex"/>
        </StackPanel>
    </Grid>
</Window>

The image below illustrates the result.

See Also