我發現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