Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Commented Issue: BusyIndicator Focus Handling Improvement [17753]

$
0
0
As discussed in this discussion thread, http://wpftoolkit.codeplex.com/discussions/263045, if a IsBusyIndicationVisible property can be added to BusyIndicator, then the existing focus lost issue can be easily resolved. Please try to provide this property in the future.
Comments: ** Comment from web user: eilefh **

JobaDiniz' method isn't very useful in a MVVM scenario, however you can subclass the BusyIndicator class and add a dependency property for the element for which to focus like this:

public class MyBusyIndicator : BusyIndicator
{
public UIElement SetFocusTo
{
get { return (UIElement)GetValue(SetFocusToProperty); }
set { SetValue(SetFocusToProperty, value); }
}

public static readonly DependencyProperty SetFocusToProperty =
DependencyProperty.Register("SetFocusTo", typeof(UIElement), typeof(MyBusyIndicator), new PropertyMetadata(null));

public MyBusyIndicator()
: base()
{
}

protected override void OnIsBusyChanged(System.Windows.DependencyPropertyChangedEventArgs e)
{
base.OnIsBusyChanged(e);

var element = this.SetFocusTo;
if (element == null)
{
return;
}

element.Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() => element.Focus()));
}
}

and in XAML:

<v:MyBusyIndicator IsBusy="{Binding IsBusy}" SetFocusTo="{Binding ElementName=searchText}">
<TextBox x:Name="searchText" />
</v:MyBusyIndicator>


Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>