开发者

Passing a TextBox.Text into command

How could I pass a parameter into command like this

<TextBox x:Name="txtSearch" />
                    <Button Content="Search" Name="btnSearch" >
                        <Custom:Interaction.Triggers>
                            <Custom:EventTrigger EventName="Click">
                                <mx:EventToCommand Command="{Binding SearchCommand, Mode=OneWay}" 
                                                   CommandParameter=txtSearch.Text />
                            </Custom:EventTrigger>
                        </Custom:Interaction开发者_开发百科.Triggers>
                    </Button>

Thanks !


If you use:

<mx:EventToCommand Command="{Binding SearchCommand, Mode=OneWay}" 
                   PassEventArgsToCommand="True" />

In the handler you can cast the sender to a TextBlock and then query it's Text property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜