我编写了一个自定义ICommand
实现,可作为静态属性使用:
public class GridViewCommands
{
public GridViewCommands()
{
}
/// <summary>
/// Toggle Selection-Command
/// </summary>
public static ICommand ToggleSelection
{
get
{
return new GridViewToggleSelectionCommand();
}
}
}
我尝试将此属性绑定到一个简单的Button-Command
<ui:GridViewControl x:Name="gridView" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
<Button HorizontalAlignment="Left" Width="100" Margin="220,0,0,0" Content="Toggle" x:Name="toggleButton" Command="{x:Static ui:GridViewCommands.ToggleSelection}" CommandParameter="{Binding ElementName=gridView}"></Button>
但是如果我启动我的应用程序,方法 in 中的parameter
-Parameter始终为空。我的目标是传递一个实例作为命令参数。CanExecute
GridViewToggleSelectionCommand
GridViewControl
我在这里做错了什么:ui:GridViewCommands.ToggleSelection}" CommandParameter="{Binding ElementName=gridView"}
?
编辑
绑定不会引发任何异常。
非常感谢!