I'll start off and say I am not using the MVVM pattern for my WPF app. Please forgive me.
Right now I have a data template with two buttons, each binds to a different command on the CLR object this data template represents. Both use the same command parameter. Here's an example of the buttons.
<Button x:Name="Button1"
Command="{Binding Path=Command1}"
CommandParameter="{Binding Path=Text, ElementName=TextBox1}"
/>
<Button x:Name="Button2"
Command="{Binding Path=Command2}"
CommandParameter="{Binding Path=Text, ElementName=TextBox1}"
/>
I would like to refactor this into a single button that can perform either command based on a user setting like a boolean in Settings.settings. I don't have access to refactoring the CLR object itself. Also this is a Data Template there isn't codebehind for me to work with. My take is that a converter would be the best bet, but I don't know how I would put that together.
The converter would need to take in the CommandParameter, as well as the DataContext so it knows which object to execute the Commands on.
Can someone lend me a hand with this? Thanks in advance.