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:
And c#:
<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; |
} |
} |
} |