private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (e.NewValue is bool) { var visible = (bool)e.NewValue; if (visible) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, () => this.BankBalance.Focus()); } } } }