私はエクスプレッション ブレンドを使用しています。リスト ボックスに要素がない場合、テキスト ボックスの状態を赤い枠線と赤いテキストに変更したいと考えています。
したがって、テキストが変更されると、リストボックスをフィルタリングします。
private void OnIPAddressTextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
compositeViewModel.manualServerInfoViewModel.FilterServers(IPAddressTextbox.Text);
}
私のビューモデルでは、結果をフィルタリングし、結果があるかどうかを確認します。次に、それに応じてブール値のプロパティを設定します
public bool HasResults { get; set; }
public void FilterServers(string FilterCriteria)
{
....
HasResults = (FilteredManualServers.Count > 0)? true : false;
}
私のxamlでは、HasResultsブール値がfalseの場合、テキストボックスのStateを赤い枠線でvisualstateに変更しようとしています。
<TextBox x:Name="IPAddressTextbox" Height="27.24" Margin="-92.799,8,0,0" VerticalAlignment="Top" Width="209" Background="#FFF3F3F3" BorderBrush="#FF2F2F2F" TextChanged="OnIPAddressTextChanged" >
<i:Interaction.Behaviors>
<ei:DataStateBehavior Binding="{Binding HasResults}" TrueState="NoResults" />
</i:Interaction.Behaviors>
</TextBox>
そして、これは NoResult ビジュアルステートです
<VisualStateGroup x:Name="Filtering">
<VisualState x:Name="NoResults">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="IPAddressTextbox">
<EasingColorKeyFrame KeyTime="0" Value="Red"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="IPAddressTextbox">
<EasingColorKeyFrame KeyTime="0" Value="#FFCE1010"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
ただし、項目数が空でブール値が false の場合、何も起こりません。
私は何を間違っていますか?