I am trying to use EventArgsConverter on my project, based on this post:
(https://github.com/microsoft/XamlBehaviorsWpf/pull/14)
My problem is that I am not sure where b is referring to? Or where can I download a full sample?
I am trying to use EventArgsConverter on my project, based on this post:
(https://github.com/microsoft/XamlBehaviorsWpf/pull/14)
My problem is that I am not sure where b is referring to? Or where can I download a full sample?
The b: is the xmlns reference to xaml behaviors which is now a nuget package
See
https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/
As in
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
Working markup and code:
xmlns:b="http://schemas.microsoft.com/xaml/behaviors">
<Window.DataContext>
<local:MainWindowViewModel/>
</Window.DataContext>
<Grid>
<Button>
<b:Interaction.Triggers>
<b:EventTrigger EventName="Click">
<b:InvokeCommandAction Command="{Binding TestCommand}" />
</b:EventTrigger>
</b:Interaction.Triggers>
</Button>
</Grid>
</Window>
Viewmodel:
public class MainWindowViewModel
{
private ICommand _testCommand;
public ICommand TestCommand
{
get
{
if (_testCommand == null)
{
_testCommand = new RelayCommand(
p => true,
p => this.TestMethod());
}
return _testCommand;
}
}
public void TestMethod()
{
MessageBox.Show("It worked !!!");
}
}
When I click the button, the messagebox appears.