This is a migrated thread and some comments may be shown as answers.

[Solved] Right align the numeric value

4 Answers 170 Views
NumericBox for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bevan
Top achievements
Rank 1
Bevan asked on 29 Aug 2013, 06:45 PM
Is it possible to right align the numeric value in the Numeric Box control?

I did try these, but seem to have no affect;

numericBoxPicker.HorizontalContentAlignment = HorizontalAlignment.Right;
numericBoxPicker.HorizontalAlignment = HorizontalAlignment.Right;



4 Answers, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 30 Aug 2013, 03:05 PM
Hi Bevan,

Thank you for your question.

To change the properties that define the appearance of the text box part of the RadNumericBox control, you have to define an implicit style that targets the NumericTextBox class (defined in the Telerik.UI.Xaml.Controls.Input.NumericBox namespace) in the resources of the control:

<telerikInput:RadNumericBox>
    <telerikInput:RadNumericBox.Resources>
        <Style TargetType="telerikNumericBox:NumericTextBox">
            <Setter Property="TextAlignment" Value="Right"/>
        </Style>
    </telerikInput:RadNumericBox.Resources>
</telerikInput:RadNumericBox>

I hope this helps and do not hesitate to contact us if you have any other questions or ideas. Regards,
Rositsa Topchiyska
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Bevan
Top achievements
Rank 1
answered on 30 Aug 2013, 05:12 PM
Thanks, I'll give this a try, but can it also be done in C# codebehind?
0
Rosy Topchiyska
Telerik team
answered on 02 Sep 2013, 11:37 AM
Hi Bevan,

This is how you can define an implicit style in code behind:

Style numericTextBoxStyle = new Style();
numericTextBoxStyle.TargetType = typeof(NumericTextBox);
numericTextBoxStyle.Setters.Add(new Setter() { Property = NumericTextBox.TextAlignmentProperty, Value = TextAlignment.Right });
numericBox.Resources.Add(typeof(NumericTextBox), numericTextBoxStyle);
Where:
<telerikInput:RadNumericBox x:Name="numericBox"/>

I hope this was useful. Let us know if there is anything else we can assist you with.

Regards,
Rositsa Topchiyska
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.


<telerikInput:RadNumericBox x:Name="numericBox"/>

<telerikInput:RadNumericBox x:Name="numericBox"/>

0
Bevan
Top achievements
Rank 1
answered on 04 Sep 2013, 07:14 PM
Thanks that worked for the alignment issue.
Tags
NumericBox for XAML
Asked by
Bevan
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Bevan
Top achievements
Rank 1
Share this question
or