我想将命令绑定到文本框。我试过下面的代码。但它没有用。
<TextBox x:Name="txtReview" MaxLength="1000" Text="{Binding Mode=TwoWay,Path=Comments}" HorizontalAlignment="Left" Height="215" Margin="10,184,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="326" InputScope="Default" VerticalScrollBarVisibility="Auto">
<i:Interaction.Triggers>
<i:EventTrigger>
<i:InvokeCommandAction Command="{Binding textchangedcommand, Mode=OneWay}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
答案 0 :(得分:2)
这可以解决您的问题:
<TextBox x:Name="txtReview" MaxLength="1000" Text="{Binding Mode=TwoWay,Path=Comments}" HorizontalAlignment="Left" Height="215" Margin="10,184,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="326" InputScope="Default" VerticalScrollBarVisibility="Auto">
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{Binding textchangedcommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>