Quantcast
Channel: WPF and initial focus - Stack Overflow
Browsing latest articles
Browse All 13 View Live

Answer by BrightShadow for WPF and initial focus

Above solution was not working as expected for me, I've changed slightly the behavior proposed by Mizipzor as following:From this partif ((bool)args.NewValue) { control.Loaded += (sender, e) =>...

View Article



Answer by G.Dealmeida for WPF and initial focus

If you are like me, and you are using some frameworks that, somehow, mess up with the basic focus behaviors, and make all solutions above irrelevant, you can still do this :1 - Note the element which...

View Article

Answer by Drew Noakes for WPF and initial focus

A minimal version of Mizipzor's answer for C# 6+.public static class FocusBehavior{ public static readonly DependencyProperty GiveInitialFocusProperty =...

View Article

Answer by BSG for WPF and initial focus

I also faced the same problem. I had three text boxes inside canvas container and wanted the first text box to be focused when the user control opens. WPF code followed MVVM pattern. I created a...

View Article

Answer by Simon Gillbee for WPF and initial focus

You can easily have the control set itself as the focused element in XAML.<Window><DataGrid FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}">...

View Article


Answer by Vladik Y for WPF and initial focus

Had same problem solved it with simple solution:In the main window:<Window .... FocusManager.FocusedElement="{Binding ElementName=usercontrolelementname}" ... />In the user control:private void...

View Article

Answer by dnk.nitro for WPF and initial focus

<Window FocusManager.FocusedElement="{Binding ElementName=yourControlName}">

View Article

Answer by Mizipzor for WPF and initial focus

Based on the accepted answer implemented as an attached behavior:using System.Windows;using System.Windows.Controls;using System.Windows.Input;namespace UI.Behaviors{ public static class FocusBehavior...

View Article


Answer by OrPaz for WPF and initial focus

After having a 'WPF Initial Focus Nightmare' and based on some answers on stack, the following proved for me to be the best solution. First, add your App.xaml OnStartup() the...

View Article


Answer by Sean for WPF and initial focus

This works, too:<Window FocusManager.FocusedElement="{Binding ElementName=SomeElement}"><DataGrid x:Name="SomeElement"> ...</DataGrid></Window>

View Article

Answer by Joe White for WPF and initial focus

I found another possible solution. Mark Smith posted a FirstFocusedElement markup extension for use with FocusManager.FocusedElement.<UserControl x:Class="FocusTest.Page2"...

View Article

Answer by Joe White for WPF and initial focus

I had the bright idea to dig through Reflector to see where the Focusable property is used, and found my way to this solution. I just need to add the following code to my Window's constructor:Loaded +=...

View Article

WPF and initial focus

It seems that when a WPF application starts, nothing has focus.This is really weird. Every other framework I've used does just what you'd expect: puts initial focus on the first control in the tab...

View Article

Browsing latest articles
Browse All 13 View Live




Latest Images