Silverlight / WPF - Focus only on WPF usercontrol
Asked By Lokesh M
03-Feb-12 09:55 AM
Hi,
Background:
Have a window in wpf called "Window1.xaml" it contains a button(button1) control and a textbox(textbox1)
On click of button1, it displays usercontrol(visibility set to true).
Problem:
when end user press keyboard tab button, it is focusing on textbox1 and button1 too.
rather, would expect to focus only on the controls present in usercontrol.
plz advise.
thanks
Lokesh.
Robbe Morris replied to Lokesh M
Do your own homework. You write the code and then if you something specific in "your" code, post your question here.
D Company replied to Lokesh M
Hello Friend.
The best option to achieve this is attach an event handler to the tab event of the control present in user control that event handler change the focus.
So say you have textBox1 present in user control. In the tab event handler for textBox1 you can do something like this.
private void textBox1_Tab(object sender, KeyEventArgs e)
{
if (e.Key == Key.Tab)
textBox1.Focus();
}
give a try to this approach, and cutomize it according to your plan, will help you.
Regards
D
[)ia6l0 iii replied to Lokesh M
If you want an element not to be focused, as in your case, you need to set its
Focusable property to false. You can also use the "FocusVisualStyle" attribute.
So, Set the Focusable property on the textbox1 and button1 to false.
Let me know If I have misunderstood you.

to avoid special character entry in xaml form.(urgent) i am using the textbox in silverlight xaml form in mvvm pattern with decimal value i want to avoid entry of special to avoid special char in textbox by using regular expression private void InputValue2_KeyDown(object sender, KeyEventArgs e) { if (e.Key = = Key.Tab) { } else { var thisKeyStr = ""; if (e.PlatformKeyCode = = 190 | | e.PlatformKeyCode IgnoreCase" / > < / Binding.ValidationRules > < / Binding > < / TextBox.Text > < / TextBox > http: / / www.eggheadcafe.com / community / xaml / 56 / 10051344 / wpf-textbox-validation.aspx Regards. you can listen to the PreviewTextInput event instead of the KeyDownEvent avoid, special, character, entry, in, xaml, form.(urgent) description: i am using the textbox in silverlight xaml form in mvvm pattern with decimal value i want to avoid entry of special
Silverlight Toolkit: Autocomplete TextBox Stock Symbols and Chart In a previous article, I presented an example of creating stock charts using the Silverlight Toolkit Charting control, getting the price history data "on demand" from Yahoo Finance. At that also provide a CSV format text file of over 20, 000 current stock symbols The Silverlight Toolkit is a work in progress, with controls listed in three different categories of "feature above is our predicate for the filtering process. Now let's switch over to the Silverlight client and see what happens "under the hood" when you start typing in the Autocomplete symbol, DateTime.Now.AddYears(-2), DateTime.Now); } private void autoComplete1_KeyUp( object sender, System.Windows.Input.KeyEventArgs e) { if (autoComplete1.Text.Length <3) return ; autoComplete1.Populating + = (s, args) = > { args.Cancel = true ; var going to get better very shortly. In fact, they are going to add it to WPF next. Yep, Silverlight first, WPF later. Go Figure! You can download the full Visual Studio 2008 solution here , including the
Number and Decimal value validation in wpf hello frnd i am working wpf application. i want to number validation and decimal validation in text box. how to do above if user input is invalid, TextBox will have a red border. Like everything in WPF it is possible to customize it by setting a custom ControlTemplate. My template shows a color: #606060; } CorrectValue IncorrectValue Refrence from : http: / / weblogs.asp.net / monikadyrda / archive / 2009 / 06 / 24 / wpf-textbox-validation.aspx hi, Here's the final code private void cvalue_PreviewTextInput( object sender, System Text))) && (cvalue.Text.IndexOf( "." ) = = -1))) { e.Handled = false ; } } void cvalue_PreviewKeyDown( object sender, System.Windows.Input.KeyEventArgs e) { if ((cvalue.Text = = "" )) { calc_btn.IsEnabled = false ; } else { calc_btn.IsEnabled = true ; } } Hope this will help Can only Handle TextBoxes"); } There is now a much better way to do this in WPF and Silverlight. If your control is bound to a property, all you have to do is change to handle KeyDown or KeyPressed event to get character and check whether it number. In WPF world, there are a lot of ways to input anything, that text (for example Voice
WPF Datagrid as ComboBox Dropdown Part 2 This presents a WPF custom control derived from ComboBox that shows a DataGrid to display the ComboBox items. Introduction a custom control. Deriving from ComboBox Before anything else, first create a project of type WPF Custom Control Library, so that things are automatically created for us. Our first goal is 2006 / xaml" xmlns:controls = "clr-namespace:CustomControls;assembly = CustomControls" xmlns:toolkit = "http: / / schemas.microsoft.com / wpf / 2008 / toolkit" xmlns:local = "clr-namespace:DemoApp" Title = "MainWindow" Height = "300" Width = "300"> < Grid > <Grid You can download the Visual Studio 2008 solution here . Note that you need to have WPF Toolkit installed to run the application. Popularity ( 8512 Views ) View Michael Detras's Articles Biography - Michael Detras .NET developer. Interested in WPF, Silverlight, and XNA. My blog My FAQs Create New Account Article Discussion WPF Datagrid as ComboBox Dropdown Part 2 Michael Detras posted at Monday, March 22, 2010 5
silverlight and wpf difference if one person has gain master in silverlight than wiil this help him in learning wpf Hi Malik, WPF has a more advanced and mature XAML support than Silverlight. Silverlight used to be called (WPF / E) and is a subset of the WPF XAML design. Therefore, it doesn't support