Я пытаюсь установить VisualState для TextBox через код.
<TextBox x:Name="txtbox" Width="438" Height="56" Style="{StaticResource ExtendeTextBoxStyle}"
PlaceholderText="{x:Bind PlaceholderText, Mode=OneWay}" ></TextBox>
Codebehind
private static void HasErrorUpdated(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
EditTextControl textBox = d as EditTextControl;
Grid sds = textBox.Content as Grid;
var mytxt = sds.Children.FirstOrDefault() as Control;
if (textBox != null)
{
if (textBox.HasError)
VisualStateManager.GoToState(mytxt , "InvalidState", true);
else
VisualStateManager.GoToState(mytxt, "ValidState", false);
}
}
Но это визуальное состояние никогда не активируется. Что здесь не так?