FocusFirstControl Behavior

Jun 4, 2012 at 4:41 PM

Hi Geert,

how about adding the following simple FocusFirstControl behavior for users which cannot use the DataWindow (like me)?


    public class FocusFirstControl : BehaviorBase<FrameworkElement>
        public static readonly DependencyProperty FocusParentsFirstProperty =
                "FocusParentsFirst", typeof(bool), typeof(FocusFirstControl), new PropertyMetadata(true));

        public bool FocusParentsFirst
                return (bool)this.GetValue(FocusParentsFirstProperty);

                this.SetValue(FocusParentsFirstProperty, value);

        protected override void OnAssociatedObjectLoaded(object sender, EventArgs e)
	    base.OnAssociatedObjectLoaded(sender, e);
many thanks!
Jun 4, 2012 at 4:42 PM

Seems like a good idea. I will add this ASAP (but very busy this week, probably not much work for Catel)

Jun 4, 2012 at 5:45 PM

Btw, the Focus does not work for you?

Jun 4, 2012 at 6:33 PM

many thanks for adding it. FocusFirstControl seems to me a better choice in a windowed environment and it is easier to let the behavior find the first control for the focus.

Jun 5, 2012 at 7:13 PM

This feature is added, I will release a new nuget package tonight.

Jun 6, 2012 at 10:17 AM

Works perfectly! thanks