WPF Commands and Parameters


Question

I'm finding the WPF command parameters to be a limitation. Perhaps that's a sign that I'm using them for the wrong purpose, but I'm still giving it a try before I scrap and take a different tack.

I put together a system for executing commands asynchronously, but it's hard to use anything that requires data input. I know one common pattern with WPF commands is to pass in this. But this will not work at all for asynchronous commands because all the dependency properties are then inaccessible.

I end up with code like this:

<Button Command="{Binding ElementName=servicePage, Path=InstallServiceCommand}">
  <Button.CommandParameter>
     <MultiBinding Converter="{StaticResource InstallServiceParameterConverter}">
        <MultiBinding.Bindings>
           <Binding ElementName="servicePage" Path="IsInstalled"/>
           <Binding ElementName="localURI" Path="Text"/>
           <Binding ElementName="meshURI" Path="Text"/>
           <Binding ElementName="registerWithMesh" Path="IsChecked"/>
         </MultiBinding.Bindings>
      </MultiBinding>
  </Button.CommandParameter>
</Button>

and also need the InstallServiceParametersConverter class (plus InstallServiceParameters).

Anyone see an obvious way to improve upon this?

1
4
5/23/2017 11:56:51 AM

Let me point you to my open source project Caliburn. You can find it at here. The feature that would most help solve your problem is documented briefly here

2
3/18/2015 1:56:50 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon