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.
精彩评论