Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
Right Align text in a SegmentedDisplay
posted

Is there a way to change the alignment of text in a SegmentedDisplay?  I can pad it with spaces, but I'd really rather just have it right aligned for numeric input like on a calculator.  I have tried several things to no avail.

Parents
No Data
Reply
  • 12004
    Suggested Answer
    posted

    Hello Llaslo,

    By default the text shown on the XamSegmentedDisplay is stretched. As far as alignment the ContentPresenter element's HorizontalAlignment can be set to Right. In each of the segments can be set to a fixed width with matching the number of characters using Digits from the Text property. E.g.:

    <Style TargetType="local:XamSegmentedDisplay">
            <Setter Property="Background" Value="Black" />
            <Setter Property="TextForeground" Value="White" />
            <Setter Property="TextForegroundUnlit" Value="#25FFFFFF" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="local:XamSegmentedDisplay">
                        <Border Background="{TemplateBinding Background}">
                            <ContentPresenter x:Name="RootElement" HorizontalAlignment="Right"  />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
    </Style>

    <Style TargetType="local:SevenSegmentDigit">
            <Setter Property="Width" Value="15" />
    </Style>

    <ig:XamSegmentedDisplay SegmentMode="SevenSegment"
    Digits="5" Text="ABCDE" Margin="0,0,0,15" Height="64" />

    Let me know if I can provide any further assistance.

Children
No Data