【问题标题】:How to bind command to the textbox in windows phone如何将命令绑定到 windows phone 中的文本框
【发布时间】:2013-11-23 11:32:55
【问题描述】:

我想将命令绑定到文本框。我试过下面的代码。但它不起作用。

<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>

【问题讨论】:

  • 您应该检查问题的答案,并在解决问题后立即将最佳答案标记为已接受。如果答案缺少任何内容或无法解决您的问题,您应该在下面发表评论。

标签: mvvm windows-phone-8


【解决方案1】:

这应该可以解决您的问题:

<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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-05
    • 2016-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    相关资源
    最近更新 更多