66480

How to set focus on NumericUpDown control?

I am trying to set focus on NumericUpDown element from WPFs extended toolkit. I heve following XAML

<Window ... xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" <Grid> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal" FocusManager.IsFocusScope="True"> <extToolkit:NumericUpDown HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="ItemsCount" Value="1"/> <TextBlock Text="XXX" Margin='10,0,0,0'/> </StackPanel> </Grid> </Window>

I called Keyboard.Focus(ItemsCount) and ItemsCount.Focus() from constructor and from Loaded event with no success. Control is getting focus when I press Tab, but in my case it is not acceptable. I didn't found enything on google as well. Is there any way to focus NumericUpDown?

P.S. Calling Focus() works for TextBox so it's must be control specific issue.

Answer1:

Maybe it is not set to be focusable, have you checked the value of Focusable?

Answer2:

Set the SelectAllOnGotFocus property to True

Recommend

  • Clr namespace mapping to default xaml namespaces
  • Styling ListBoxItem's of nested ListBoxes [WPF]
  • Not able to stretch an inner StackPanel
  • How to align text in a WPF menu item?
  • WPF MVVM WinformsHost with OpenGL-Control
  • UWP Template 10 create a dynamic hamburgermenu
  • Using ListPicker and DataBinding
  • Binding Selected RowCount to TextBlock not Firing OnPropertyChanged after DataGrid Scroll
  • Visualizing 2D Data in a Table
  • WPF8/C# - Binding Data To Grid
  • Customizing sublayout caching in Sitecore
  • Detaching entity along with referenced entities
  • Powerpoint 2010 VSTO AddIn taskpane on multiple Windows
  • How to clip image to ellipse in XAML
  • Complex Silverlight TreeView, is nested hierarchy possible?
  • How to delete a newline using \\b
  • Keep transition effect on 1 div from moving the div that follows?
  • How to start server for Selenium grid Java Maven setup
  • Multibinding Multiselection ListView
  • Updating one element of a bound Observable collection
  • Allocating a 2D contiguous array within a function
  • How to convert WPF project so it can be used as a class library by a separate exe
  • Set step size polar plot matplotlib python
  • Android Lock Screen C# .NET Replica
  • Caliburn Micro, How to use ContentControl (or display 'sub' ViewModel) using ViewModel Fir
  • How to rotate the dial in a gauge chart? Using python plotly
  • Dynamically load css stylesheet and wait for it to load
  • Plotting densities in R
  • WP8.1 AppBarButton holding event
  • Update Google Maps traffic layer without page reloading
  • Installing iPhone App to iPhone
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • JTable with a ScrollPane misbehaving
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize