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

RadNumericUpDown non-visible initial value when initially focused by FocusManager.FocusedElement="{Binding ..}"

3 Answers 277 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Ian Verona
Top achievements
Rank 1
Ian Verona asked on 14 Nov 2014, 10:22 AM
I have an issue where the initial value of a RadNumericUpDown is not visible, when focused by FocusManager.FocusedElement in xaml.

If FocusManager is removed or you tab out of the input-field, the value showed correctly.

A little bug, but big usability-impact in our application.

Telerik version: 2014.3.1021.40
Visual Studio version: Premium 2012

Screendump attached.
I have a small POC app if required.

3 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 17 Nov 2014, 11:46 AM
Hello Ian,

Can you please share some sample code that demonstrates the exact implementation as I was not able to reproduce the described issue?

I'm looking forward to hearing from you.

Regards,
Kalin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Ian Verona
Top achievements
Rank 1
answered on 17 Nov 2014, 01:30 PM
Hi Kalin.

Thanks for your response. 
I can only attach images, so I'll paste code here :)

Xaml:
<Window x:Class="RadNumericTextBoxFocusTest.MainWindow"
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
        Title="MainWindow" Height="350" Width="525"
        FocusManager.FocusedElement="{Binding ElementName=UpDown}">
    <Grid>
        <StackPanel>
            <telerik:RadNumericUpDown
                Minimum="1"
                Maximum="20"
                Value="{Binding SomeInt, UpdateSourceTrigger=PropertyChanged}"
                Name="UpDown"/>
            <TextBox />
        </StackPanel>
    </Grid>
</Window>

Code behind:
/// <summary>
   /// Interaction logic for MainWindow.xaml
   /// </summary>
   public partial class MainWindow : Window
   {
       public MainWindow()
       {
           InitializeComponent();
       }
 
       protected override void OnInitialized(EventArgs e)
       {
           base.OnInitialized(e);
 
           DataContext = new Aclass() {SomeInt = 10};
       }
 
        
   }
 
   public class Aclass : ViewModelBase
   {
       private int _someInt;
 
       public int SomeInt
       {
           get { return _someInt; }
           set
           {
               _someInt = value;
               OnPropertyChanged(() => SomeInt);
           }
       }
   }

Thanks in advance.

/Ian V. Andersen
0
Kalin
Telerik team
answered on 18 Nov 2014, 12:06 PM
Hello Ian,

The observed behavior is caused by the fact that the NumericUpDown gets focused before the DataContext is set. In order to get it working correctly you can set the DataContext above InitializeComponent:

public MainWindow()
{
    DataContext = new Aclass() { SomeInt = 10 };
    InitializeComponent();
}

Hope this helps.

Regards,
Kalin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
NumericUpDown
Asked by
Ian Verona
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Ian Verona
Top achievements
Rank 1
Share this question
or