2010-12-01 4 views
0

DependencyProperty (예 : MyEffect)를 만들고이 속성을 내 텍스트 상자에 사용합니다. PropertyChangedCallback 기능에서 DependencyProperty에서 VisualStateManager.GoToState를 호출하면 작동하지 않습니다.

<TextBox Grid.Row="0" x:Name="MyTextBox"       
         Text ="{Binding Model.MyValue}"        
         behaviors:MyEffect="{Binding EffectSample}"> 
</TextBox> 

, 나는 "안녕하세요"

myControl.SetValue(TextBox.TextProperty, "Hello"); 
VisualStateManager.GoToState(myControl, "InvalidFocused", true); 

내 텍스트 상자의 표시를 호출 할 수 있습니다 만, 그 상태는 InvalidFocused 변경되지 않습니다. 그렇다면 어떻게 내 텍스트 상자의 상태를 바꿀 수 있습니까?

답변

0

이것은 내 머리 꼭대기에서 벗어나지 만 GotToState 메서드에 전달하는 유형일 수 있습니다. 그것은 컨트롤을 기대하므로 myControl이 DependencyProperty로 전달되고 있다고 가정하고 다음을 수행합니다.

var control = myControl as Control;
VisualStateManager.GoToState(myControl, "InvalidFocused", true);

관련 문제