Skip to content

Instantly share code, notes, and snippets.

@wegorich
Last active December 11, 2015 01:29
Show Gist options
  • Save wegorich/4523696 to your computer and use it in GitHub Desktop.
Save wegorich/4523696 to your computer and use it in GitHub Desktop.
Binding WPF command using WPFToolkit.Extended
//xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
//xmlns:toolkit="clr-namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended"
<toolkit:WatermarkTextBox Padding="6,4"
TextOptions.TextRenderingMode="Aliased" Watermark="Введите что нибудь для поиска" >
<toolkit:WatermarkTextBox.BorderBrush>
<SolidColorBrush Color="#DDD"/>
</toolkit:WatermarkTextBox.BorderBrush>
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="TextChanged">
<wpfTools:EventToCommand PassEventArgsToCommand="True" Command="{Binding AllSearch}"></wpfTools:EventToCommand>
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
</toolkit:WatermarkTextBox>
//in code
private RelayCommand<EventArgs> _allSearchCommand;
public ICommand AllSearch
{
get
{
return _allSearchCommand ?? (_allSearchCommand = new RelayCommand<EventArgs>(
e =>
{
var search = ((WatermarkTextBox)((TextChangedEventArgs)e).Source).Text;
}));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment