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

4 posts, 0 answers
  1. Ian Verona
    Ian Verona avatar
    2 posts
    Member since:
    Nov 2014

    Posted 14 Nov 2014 Link to this post

    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.
  2. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 17 Nov 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ian Verona
    Ian Verona avatar
    2 posts
    Member since:
    Nov 2014

    Posted 17 Nov 2014 in reply to Kalin Link to this post

    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
  5. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 18 Nov 2014 Link to this post

    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.

     
Back to Top