【发布时间】:2010-08-19 08:48:29
【问题描述】:
我正在研究将 MVVM 模式用于我的 Silverlight 应用程序。
以下代码来自 xaml UI 代码:
<Button Width="30"
Margin="10"
Content="Find"
Command="{Binding Path=GetCustomersCommand, Source={StaticResource customerVM}}"
CommandParameter="{Binding Path=Text, ElementName=tbName}"/>
<TextBox x:Name="tbName"
Width="50" />
<TextBox x:Name="tbID"
Width="50" />
以下代码来自 ViewModel 类:
public ICommand GetCustomersCommand
{
get { return new RelayCommand(GetCustomers) { IsEnabled = true }; }
}
public void GetCustomers(string name, string id)
{
// call server service (WCF service)
}
我需要传递两个参数,但是不知道如何将两个参数(id 和 name)传递给 ViewModel 类。
我想知道是否可以在 xaml 代码中而不是在代码隐藏中。
提前致谢
【问题讨论】:
标签: mvvm silverlight-4.0