我发现WPF命令参数是一个限制。也许这是一个迹象,表明我将它们用于错误的目的,但在我放弃并采取不同的方式之前,我仍然试着尝试。WPF命令和参数
我整理了一个系统executing commands asynchronously,但很难使用任何需要数据输入的东西。我知道WPF命令的一个常见模式是通过this
。但是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>
,也需要InstallServiceParametersConverter类(加上InstallServiceParameters)。
任何人都看到一个明显的方法来改善这一点?
我不明白为什么这是一个问题。因为我记得使用它,所以我使用了WPF。 这也意味着您可以随时重新使用具有不同数据源的转换器,并且不受“this”类型限制。 你能澄清你为什么觉得这是错的? – 2008-10-15 08:19:54