我有一个TextBox
绑定到string
属性ViewModel
,我有一个Button
与Command
。现在我想通过属性本身如果可能作为CommandParameter
。 这可能吗?Xaml通过绑定属性到命令
的XAML部分:
<TextBox Text="{Binding FilePath, UpdateSourceTrigger=PropertyChanged}"/>
<Button Command="{Binding BrowseCommand}" CommandParameter="{Binding FilePath}" Content="..." />
而且Command
看起来是这样,但我有什么类型把RelayCommand<?>
,而不是什么,我需要的CommandParameter
结合?
public ICommand BrowseCommand => this.browseCommand ?? (this.browseCommand = new RelayCommand<?>(this.Browse));
filepath是字符串类型我承担? – WBuck
是的,我想通过属性本身,而不是它的价值(如果可能的话) –
这是不可能的。 {绑定}解析*值*。 – mm8