I have a TextBox and a Button in my view.
Now I am checking a condition upon button click and if the condition turns out to be false, displ
I found Crucial's solution to the IsVisible problem very useful. It didn't completely solve my problem, but some extra code following the same pattern for the IsEnabled pattern did.
To the IsFocusedChanged method I added:
if (!fe.IsEnabled)
{
fe.IsEnabledChanged += fe_IsEnabledChanged;
}
And here's the handler:
private static void fe_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
var fe = (FrameworkElement)sender;
if (fe.IsEnabled && (bool)((FrameworkElement)sender).GetValue(IsFocusedProperty))
{
fe.IsEnabledChanged -= fe_IsEnabledChanged;
fe.Focus();
}
}