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

Problem with focus in RadNumericUpDown

2 Answers 114 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
hwsoderlund
Top achievements
Rank 1
hwsoderlund asked on 22 Jan 2010, 04:52 PM
When placed inside a scroll viewer the control does not receive focus properly. I've pasted some code with embedded instructions on how to replicate the bug:

<UserControl x:Class="SilverlightApplication6.MainPage" 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:teleriknav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
             xmlns:telerikbase="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
             xmlns:telerikinput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
             xmlns:local="clr-namespace:SilverlightApplication6" 
             mc:Ignorable="d" 
             Width="640" 
             Height="480"
    <Grid x:Name="LayoutRoot"
        <Grid.RowDefinitions> 
            <RowDefinition></RowDefinition
            <RowDefinition></RowDefinition
        </Grid.RowDefinitions> 
 
        <ScrollViewer> 
            <StackPanel> 
                <TextBlock TextWrapping="Wrap" 
                           Text="Click the up/down buttons. The control never receives focus. Now click in the textbox part (to the left of the actual digits). The control loses focus immediately upon receiving it."></TextBlock> 
                <telerikinput:RadNumericUpDown HorizontalAlignment="Left" 
                                               VerticalAlignment="Top" 
                                               Width="100" 
                                               GotFocus="RadNumericUpDown_GotFocus" 
                                               LostFocus="RadNumericUpDown_LostFocus"
                    <i:Interaction.Behaviors> 
                        <local:NoDecimalDigits></local:NoDecimalDigits> 
                    </i:Interaction.Behaviors> 
                </telerikinput:RadNumericUpDown> 
            </StackPanel> 
        </ScrollViewer> 
 
        <TextBox x:Name="TxtTrace" 
                 IsReadOnly="True" 
                 HorizontalAlignment="Stretch" 
                 VerticalAlignment="Stretch" 
                 TextWrapping="Wrap" 
                 Grid.Row="1"></TextBox> 
 
    </Grid> 
</UserControl> 
 


And c#:
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using System.Windows.Controls.Primitives; 
using System.Diagnostics; 
using Telerik.Windows.Controls; 
using System.Windows.Interactivity; 
using System.Globalization; 
 
namespace SilverlightApplication6 
    public partial class MainPage : UserControl 
    { 
        public MainPage() 
        { 
            InitializeComponent();             
        } 
 
        private void RadNumericUpDown_GotFocus(object sender, RoutedEventArgs e) 
        { 
            TxtTrace.Text += "GotFocus" + Environment.NewLine; 
        } 
 
        private void RadNumericUpDown_LostFocus(object sender, RoutedEventArgs e) 
        { 
            TxtTrace.Text += "LostFocus" + Environment.NewLine; 
        } 
    } 
 
    public class NoDecimalDigits : Behavior<RadNumericUpDown> 
    { 
        protected override void OnAttached() 
        { 
            this.AssociatedObject.Loaded += AssociatedObject_Loaded; 
 
            base.OnAttached(); 
        } 
 
        protected override void OnDetaching() 
        { 
            this.AssociatedObject.Loaded -= AssociatedObject_Loaded; 
 
            base.OnDetaching(); 
        } 
 
        void AssociatedObject_Loaded(object sender, RoutedEventArgs e) 
        { 
            var info = new NumberFormatInfo(); 
            info.NumberDecimalDigits = 0; 
            info.PercentDecimalDigits = 0; 
            AssociatedObject.NumberFormatInfo = info; 
 
            //unhook 
            AssociatedObject.Loaded -= AssociatedObject_Loaded; 
        } 
 
 
    } 
 

2 Answers, 1 is accepted

Sort by
0
hwsoderlund
Top achievements
Rank 1
answered on 26 Jan 2010, 12:14 PM
Follow-up: There was a similar problem in RadSlider, and that was solved only moments ago. There is more information in the support ticket (275153). I am pretty sure the two issues are related.
0
Konstantina
Telerik team
answered on 29 Jan 2010, 04:31 PM
Hi,

Thank you for contacting us and sorry for the delayed response.

We were able to reproduce the problem. We will do our best to fix the issue for the next internal build. Sorry for the inconvenience that this has caused you.

If you have further questions please feel free to contact us again.

Greetings,
Konstantina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
NumericUpDown
Asked by
hwsoderlund
Top achievements
Rank 1
Answers by
hwsoderlund
Top achievements
Rank 1
Konstantina
Telerik team
Share this question
or