我正在使用 Jarloo's calendar control并对其进行一些更改以满足我的需求。我已经为此苦苦挣扎了很长时间,但我不知道是什么可能导致了我的问题。
所以,我的问题是我的命令绑定(bind)都不起作用。
<ListView Background="White"
SelectionMode="Single"
dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.UseDefaultDragAdorner="True"
ItemsSource="{Binding Typologies}"
IsEnabled="{Binding Enabled}">
<ListView.InputBindings>
<KeyBinding Key="Delete" Command="{Binding CancelDispatchCommand}" CommandParameter="{Binding SelectedItem}"/>
</ListView.InputBindings>
....
</ListView>
在这里,键绑定(bind)不起作用,但 {Binding Typologies}
和其他数据绑定(bind)都运行良好。这让我认为这不是数据上下文问题。
<Button DockPanel.Dock="Left" Margin="0,0,10,0" Content="<<" Command="{Binding ChangeDateCmd}" CommandParameter="YEAR,PREV"/>
在这里,我的命令绑定(bind)在这时根本不起作用:
<TextBlock Padding="5" Text="{Binding TargetDate, Converter={StaticResource DateConverter}, ConverterParameter=MONTH}"/>
工作得很好......
在 day.cs 中:
private ICommand cancelDispatchCommand;
public ICommand CancelDispatchCommand
{
get
{
return cancelDispatchCommand = cancelDispatchCommand ?? new ActionCommand((o) => CancelDispatch(o));
}
}
在 calendar.cs 中:
ICommand changeDateCmd;
public ICommand ChangeDateCmd
{
get
{
return changeDateCmd = changeDateCmd ?? new ActionCommand((o) => ChangeDate(o));
}
}
最佳答案
您不需要将 {Binding } 与命令名称一起使用。
Here是一个例子
关于c# - 当其他数据绑定(bind)有效时,命令绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31142970/