0
我想實現一個DataTrigger
,比如textBox1。當textBox1內的Text
是「ABC」時,我想顯示「數據匹配!」在另一個TextBox
說,textBox2。我爲此寫了下面的xaml代碼,但它不工作。我收到以下錯誤消息。此DataTriggers:它是如何工作的
'Text' member is not valid because it does not have a qualifying type name
XAML代碼:
<Window x:Class="ControlTemplateDemo.Animation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Animation" Height="300" Width="607">
<Grid>
<Border Background="White">
<StackPanel Margin="30" HorizontalAlignment="Left" Width="500" Height="209">
<TextBox Name="textBox1">
<TextBox.Triggers>
<DataTrigger Binding="{Binding Path=Text}">
<DataTrigger.Value>
<sys:String>ABC</sys:String>
</DataTrigger.Value>
<Setter TargetName="textBox2" Property="Text" Value="Data matched!"/>
</DataTrigger>
</TextBox.Triggers>
</TextBox>
<TextBox Name="textBox2">
</TextBox>
</StackPanel>
</Border>
</Grid>
</Window>
是否有約束力的任何問題嗎?
感謝, 與Hemant