2012-05-19

Articles

FocusBehavior

 

Many applications have dialogs where the users first have to type in any kind of text. It will be great if the user directly can start typing as soon the dialog is displayed. With this behavior you can define which control will get the focus as soon the window has loaded.

 

alt

 

Usage

<UserControl x:Class="DW.Interactivity.Demo.FocusBehaviorControl"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:Interactivity="http://schemas.my-libraries.de/wpf/interactivity">
	<StackPanel Interactivity:FocusBehavior.StartFocusedControl="{Binding ElementName=focusControl}">
		<TextBox Text="This control get the focus on load" x:Name="focusControl" />
	</StackPanel>
</UserControl>

 

 

Note

This control needs the DW.SharpTools.