我定义了一个ICommand,它用一个特定的WHER-子句从数据库中读取所有person对象。
该命令是通过按一个按钮来执行的,WHER-子句正在文本框中插入。
问:如何将文本从文本框传递到执行命令?
MainWindow.xaml:
<Button Command="{Binding ReadPersons}">Read persons</Button>
<TextBox Name="textBoxWhereClause" />ReadPersons.cs:
public void Execute(object parameter)
{
// Read all persons with my where-clause
string whereClause = ??? //todo
}发布于 2011-12-28 10:12:39
是的你可以。
<Button Command="{Binding ReadPersons}"
CommandParameter="{Binding Text, ElementName=textBoxWhereClause}">
Read persons</Button>发布于 2011-12-28 10:12:31
<Button Command="{Binding ReadPersons}" CommandParameter="{Binding SomeProperty}" Content="Read Persons"/>https://stackoverflow.com/questions/8654451
复制相似问题