I'm trying to bind a function with a "click" attribute of a Button,
A CLICK ATTRIBUTE, NOT A COMMAND. THANK YOU.
here is what I tried to do:
The Xaml Code line:
<Button Background="{Binding Path=motionColor}" Click="{Binding MotionButton_Click}" />
The c# relevant code: (which inside the binded object, and not the window class)
public void MotionButton_Click(object Sender, RoutedEventArgs e)
{
SendPacket(cockpitType, (byte)Index.Motion, MotionValue);
setMotion(3);
}
Some notes:
- The background binding works just fine.
- I have tried to do it as "Path=MotionButton_Click", not working either.
- Here is the error I get:
Error 1 Click="{Binding MotionButton_Click}" is not valid. '{Binding MotionButton_Click}' is not a valid event handler method name. Only instance methods on the generated or code-behind class are valid. Line 50 Position 94. c:\users\dp27317\documents\visual studio 2010\Projects\GenericSoundMotion\GenericSoundMotion\MainWindow.xaml 50 94 GenericSoundMotion
- Not sure if important but the binded collection is "ObservableCollection" of "public class GenericPanel".
All I want is that when I press on that button, the "MotionButton_Click" function will run. Everything that will make it work is a blessing, even dirty solutions.
Thank you.