开发者

Passing a TextBox.Text into command

开发者 https://www.devze.com 2023-04-12 11:13 出处:网络
How could I pass a parameter into command like this <TextBox x:Name=\"txtSearch\" /> <Button Content=\"Search\" Name=\"btnSearch\" >

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

精彩评论

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